Skip to content

Commit

Permalink
fix: resolve cache encoding issue by enforcing UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
LSauce committed Dec 31, 2024
1 parent aac2f54 commit f84a273
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# idea
.idea

# virtual env
venv
4 changes: 2 additions & 2 deletions sgpt/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ def wrapper(*args: Any, **kwargs: Any) -> Generator[str, None, None]:
key = md5(json.dumps((args[1:], kwargs)).encode("utf-8")).hexdigest()
file = self.cache_path / key
if kwargs.pop("caching") and file.exists():
yield file.read_text()
yield file.read_text(encoding='utf-8')
return
result = ""
for i in func(*args, **kwargs):
result += i
yield i
if "@FunctionCall" not in result:
file.write_text(result)
file.write_text(result, encoding='utf-8')
self._delete_oldest_files(self.length) # type: ignore

return wrapper
Expand Down

0 comments on commit f84a273

Please sign in to comment.