feat(groq): Allow kwargs in with_structured_output to override tool_choice #34053
+3
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #33995
Allow users to pass additional kwargs (like tool_choice) to with_structured_output() to avoid 400 errors when the model doesn't trigger a tool call. This aligns ChatGroq with ChatOpenAI behavior.
Users can now override the default tool_choice:
llm.with_structured_output(Schema, tool_choice="auto")
Description: Allow users to pass additional keyword arguments (like
tool_choice) to with_structured_output() to avoid 400 errors when the model doesn't trigger a tool call. This alignsChatGroq.with_structured_output()withChatOpenAI.with_structured_output()behavior by removing the kwargs restriction and passing them through to bind_tools() and bind() methods.Issue: Fixes #33995
Dependencies: None