Skip to content
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

Fixed an issue where non-ASCII characters were changed to Unicode characters within the prompt #1490

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ragas/llms/output_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_json_format_instructions(pydantic_object: t.Type[TBaseModel]) -> str:
if "title" in reduced_schema:
del reduced_schema["title"]
# Ensure json in context is well-formed with double quotes.
schema_str = json.dumps(reduced_schema)
schema_str = json.dumps(reduced_schema, ensure_ascii=False)

resp = JSON_FORMAT_INSTRUCTIONS.format(schema=schema_str)
return resp
Expand Down
2 changes: 1 addition & 1 deletion src/ragas/llms/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def format(self, **kwargs: t.Any) -> PromptValue:
)
for key, value in kwargs.items():
if isinstance(value, str):
kwargs[key] = json.dumps(value)
kwargs[key] = json.dumps(value, ensure_ascii=False).encode("utf8").decode()

prompt = self.to_string()
return PromptValue(prompt_str=prompt.format(**kwargs))
Expand Down
Loading