Skip to content

Commit 776afaa

Browse files
fix: return valid JSON output schema (#1933)
Use json.dumps() on the dict output of Pydantics's BaseModel.model_json_schema() to ensure the string representation is valid JSON using double quotes instead of single quotes.
1 parent f5ea3d5 commit 776afaa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/ragas/prompt/pydantic_prompt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def _generate_output_signature(self, indent: int = 4) -> str:
4545
return (
4646
f"Please return the output in a JSON format that complies with the "
4747
f"following schema as specified in JSON Schema:\n"
48-
f"{self.output_model.model_json_schema()}"
48+
f"{json.dumps(self.output_model.model_json_schema())}"
4949
"Do not use single quotes in your response but double quotes,"
5050
"properly escaped with a backslash."
5151
)

0 commit comments

Comments
 (0)