Skip to content

Commit

Permalink
chore: fallback to uncached if cache decode fails
Browse files Browse the repository at this point in the history
  • Loading branch information
zhudotexe committed Oct 10, 2024
1 parent 5e19c27 commit ccf127b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fanoutqa/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ def wiki_content(doc: Evidence) -> str:
# get the cached content, if available
cache_filename = WIKI_CACHE_DIR / f"{doc.pageid}-dated.md"
if cache_filename.exists():
return cache_filename.read_text(encoding="utf-8")
try:
return cache_filename.read_text(encoding="utf-8")
except UnicodeDecodeError:
pass

# otherwise retrieve it from Wikipedia
resp = wikipedia.get("", params={"format": "json", "action": "parse", "oldid": doc.revid, "prop": "text"})
Expand Down

0 comments on commit ccf127b

Please sign in to comment.