Set tool_choice
to "auto"
#526
Closed
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.
Currently,
tool_choice
is set to "required".According to OpenAI specs:
This PR sets
tool_choice
to "auto" instead. It is interesting for 2 reasons:tool_choice="required"
[Feature]: Additional possible value fortool_choice
:required
vllm-project/vllm#10526Looking at this repo's history, I see that at one point both options coexisted:
smolagents/src/smolagents/models.py
Line 295 in 117014d
I couldn't find any discussion on why it was ultimately decided to go with "required" instead of "auto".
Moreover, since
tool_choice
is explicitly set in_prepare_completion_kwargs()
, it has priority overself.kwargs
and can't be overridden by passing it toModel
.Alternatives
tool_choice
an explicit positional argument ofModel
, allowing the user to set it at initializationtool_choice
in_prepare_completion_kwargs()
, letting the LLM API engine decide on the default to use (most likely "auto" if it follows OpenAI specs) and allowing the user to override it throughself.kwargs
_prepare_completion_kwargs()
to allowtool_choice
in particular to be overridden (this would be the hardest to maintain imo)