Repository navigation
Python: write and read chat history files as UTF-8 #14745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
c2141d1
3fb8d30
3130e6e
7cba857
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -427,7 +427,7 @@ def store_chat_history_to_file(self, file_path: str) -> None: | |
| file_path: The path to the file where the serialized data will be stored. | ||
| """ | ||
| json_str = self.serialize() | ||
| with open(file_path, "w") as local_file: | ||
| with open(file_path, "w", encoding="utf-8") as local_file: | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 3fb8d30: It stores |
||
| local_file.write(json_str) | ||
|
|
||
| @classmethod | ||
|
|
@@ -442,6 +442,6 @@ def load_chat_history_from_file(cls: type[_T], file_path: str) -> _T: | |
| Returns: | ||
| ChatHistory: The deserialized ChatHistory instance. | ||
| """ | ||
| with open(file_path) as file: | ||
| with open(file_path, encoding="utf-8") as file: | ||
| json_str = file.read() | ||
| return cls.restore_chat_history(json_str) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 3fb8d30:
test_onnx_config_is_read_as_utf8inpython/tests/unit/connectors/ai/onnx/services/test_onnx_chat_completion.py.It filters
open.call_args_listdown to thegenai_config.jsoncall and assertscall.kwargs.get('encoding') == 'utf-8'on every one of them, so removing the explicit encoding fails the assertion rather than passing silently.