Skip to content

Pinned latest litellm for tool_choice=Tool's finish_reason fix #244

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

Merged
merged 2 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ lfrqa = ["aviary.lfrqa"]
litqa = ["aviary.litqa"]
llm = [
"fhlmi",
'litellm; python_version < "3.13"', # NOTE: paper-qa==5.3 doesn't support 3.13 yet
'litellm>=1.49.1; python_version >= "3.13"', # For removal of imghdr
"litellm>=1.72.0", # Pin for fixed finish_reason when specifying a tool_choice
]
server = [
"click",
Expand Down
1 change: 0 additions & 1 deletion src/aviary/tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ async def __call__(
"type": "function",
"function": {"name": tool_choice.info.name},
}
expected_finish_reason = {"stop"} # TODO: should this be .add("stop") too?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I never understood why the finish_reason was "stop" when we'd directly specified to call a Tool.

Turns out it was a litellm bug fixed sometime between litellm==1.71.1 and litellm==1.72.0

elif tool_choice is not None:
completion_kwargs["tool_choice"] = tool_choice
if tool_choice == self.TOOL_CHOICE_REQUIRED:
Expand Down
9 changes: 4 additions & 5 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.