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

fix(google-common): add tool_use param when using structured outputs #7400

Merged

Conversation

kashifmin
Copy link
Contributor

@kashifmin kashifmin commented Dec 18, 2024

When using .withStructuredOutput we need to force tool use. If not, the model tends produce an empty response and the chain eventually returns undefined.

  1. Modified tool_use param in gemini utils to handle structured output
  2. withStructuredOutput will now bind tool_use parameter
  3. anthropic utils already handles the tool use param by setting the tool use object to the function name if provided

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Dec 18, 2024
Copy link

vercel bot commented Dec 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Dec 19, 2024 7:51am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Dec 19, 2024 7:51am

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Dec 18, 2024
@kashifmin
Copy link
Contributor Author

@afirstenberg Please take a look when possible. Currently structured output breaks intermittently since tool_choice param is not set correctly.

Copy link
Collaborator

@jacoblee93 jacoblee93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thank you for this - this is a good idea

@dosubot dosubot bot added the lgtm PRs that are ready to be merged as-is label Dec 18, 2024
@jacoblee93 jacoblee93 changed the title fix: add tool_use param when using structured outputs fix(google-common): add tool_use param when using structured outputs Dec 18, 2024
@jacoblee93 jacoblee93 merged commit 82cecae into langchain-ai:main Dec 19, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature lgtm PRs that are ready to be merged as-is size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants