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

Quotes within Pydantic field of string type - JSONDecodeError in parse_value of Adapter #1968

Open
Jdogtherock opened this issue Dec 20, 2024 · 2 comments

Comments

@Jdogtherock
Copy link

I am using a Pydantic model for my output field type hint. in the model, one of the fields is a string. The LLM returns the correctly formatted json string, but it sometimes puts quotes inside the string. For example, if the field is: "reason":"the man is having "fun"", the quotes around fun is causing the JSONDecodeError in the parse_value function of the adapter. Any solutions? I am using gemini-1.5-flash-002.

@Jdogtherock
Copy link
Author

Update: I went to the json_adapter parse_value, and switched the json.loads(value) to json_repair.loads(value). it fixed the quotations. Could this be updated in the next release?

@okhat
Copy link
Collaborator

okhat commented Dec 20, 2024

Ah, very nice. Thanks @Jdogtherock ! Would you like to open a PR with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants