-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix: fallback to strict json_schema if planner response validation fails in json_mode #341
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?
fix: fallback to strict json_schema if planner response validation fails in json_mode #341
Conversation
|
Hi @WillemJiang I would appreciate if you could review this improved fix and test the models that failed with #322 |
@taxman20000 I think it could be more easy to chose the json_schema model the configuration. In this way the user has the full of the control. |
@WillemJiang Thank you for your comment. Would you like the configuration to be set in
The I think having I can update this PR if you agree with this proposal. |
|
This PR has not been merged? Is there any other solution? |
|
Hi @WillemJiang please let me know if you have any further directions on how you would like me to modify this PR to get the fix merged. |
We can add info log for the user to set to
Thanks for looking into it and working on this proposal. |
Improved fix:
This fix improves upon the reverted PR #322 because the fix in that PR was incompatible with some LLMs. In this improved PR, the
plannertries to generate a plan usingjson_modefirst and then using a strictjson_schemaif the first try fails.That means the code retains the existing
json_modewhen theplannerinitially tries to generate aPlanresponse. Only if that initial response does not comply with the required response format and the pydantic model validation throws anOutputParserException, then theplannertries to generate another plan using a strictjson_schemato force the LLM response to strictly comply with the pydanticPlanmodel. If that try also causes an exception then the user is instructed to reduce the complexity of their query.Problem:
The planner node expects an LLM response in a specific json format, but the LLM response does not always comply with that format so pydantic raises a model validation error, as reported by users in these issues:
#151
#189
#191
and possibly here:
#99
#217