-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix JsonSchemaGenerator for method input parameters #4524
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
Fix JsonSchemaGenerator for method input parameters #4524
Conversation
- For method input parameters, if the JSON schema generator adds OpenAPI "format" property, some LLMs (ex: Mistral) fail to process the request. Hence, removing this specific property from the JSON schema - This issue was uncovered by MistralAiChatModelIT#chatMemoryWithTools where the method toolcallback is used - Update tests to remove "format" from the expected JSON schema Signed-off-by: Ilayaperumal Gopinathan <[email protected]>
8326985
to
e9c9ad8
Compare
} | ||
ObjectNode parameterNode = SUBTYPE_SCHEMA_GENERATOR.generateSchema(parameterType); | ||
// Remove OpenAPI format as some LLMs (like Mistral) don't handle them. | ||
parameterNode.remove("format"); |
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.
When the parameterNode
doesn't contain "format", this operation just returns null and hence we don't need explicit check on the existence of this property.
} | ||
ObjectNode parameterNode = SUBTYPE_SCHEMA_GENERATOR.generateSchema(parameterType); | ||
// Remove OpenAPI format as some LLMs (like Mistral) don't handle them. | ||
parameterNode.remove("format"); |
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.
It would be good to find out what other cases the OpenAPI format can be used in the context of ChatClient request.
- For method input parameters, if the JSON schema generator adds OpenAPI "format" property, some LLMs (ex: Mistral) fail to process the request. Hence, removing this specific property from the JSON schema - This issue was uncovered by MistralAiChatModelIT#chatMemoryWithTools where the method toolcallback is used - Update tests to remove "format" from the expected JSON schema Fixes #4524 Signed-off-by: Ilayaperumal Gopinathan <[email protected]> (cherry picked from commit 30001ac)
…4524) - For method input parameters, if the JSON schema generator adds OpenAPI "format" property, some LLMs (ex: Mistral) fail to process the request. Hence, removing this specific property from the JSON schema - This issue was uncovered by MistralAiChatModelIT#chatMemoryWithTools where the method toolcallback is used - Update tests to remove "format" from the expected JSON schema Auto-cherry-pick to 1.0.x Fixes spring-projects#4524 Signed-off-by: Ilayaperumal Gopinathan <[email protected]> Signed-off-by: 家娃 <[email protected]>
Auto-cherry-pick to 1.0.x
Fixes #4524