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

genai: fix function_utils to parse object/array json schemas properly #715

Merged
merged 2 commits into from
Feb 4, 2025

Conversation

RazCrimson
Copy link
Contributor

The existing code tries to handle arrays and objects in anyOf fields of JSON Schema's for tools by picking the last possible non nullable choice in anyOf. But the context of the field is not updated to reflect the selected choice leading to a borked conversion to protobuf that fails with 400 errors.

This fix is just to update the context for arrays and objects.

Please correct me if it is intentional, but there is already a testcase which is supposed to cover this, but it is buggy as it sets an items field within an items definition for an array, which should not be possible according to the JSON Schema spec. The faulty setting made this bug slip through the tests

@lkuligin
Copy link
Collaborator

thanks for the change, please, fix linting errors.

I'm not sure it's a bug, we probably have it intentianally since old models didn't support AnyOf fields. But anyways, it shouldn't prevent us from fixing this.

@RazCrimson RazCrimson force-pushed the main branch 2 times, most recently from 1cb6710 to e1b291c Compare February 3, 2025 12:04
@RazCrimson
Copy link
Contributor Author

@lkuligin Fixed lint errors

PTAL

@lkuligin lkuligin merged commit a0027c8 into langchain-ai:main Feb 4, 2025
15 checks passed
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

Successfully merging this pull request may close these issues.

2 participants