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

Fixing finish_reason validation to allow tool_calls #64

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

jamesbraza
Copy link
Collaborator

#60 added validation of the finish_reason to help paper-qa CI. However, it seems the validation is overly aggressive, as in CI we now see:

aviary.message.MalformedMessageError: Expected finish reason 'stop' in LiteLLM model response, got 'tool_calls', full response was ModelResponse(id='<redacted>', choices=[Choices(finish_reason='tool_calls', index=0, message=Message(content=None, role='assistant', tool_calls=[ChatCompletionMessageToolCall(function=Function(arguments='{"query":"XAI for chemical property prediction","min_year":2018,"max_year":2024}', name='paper_search'), id='<redacted>', type='function')], function_call=None))], created=1728430225, model='gpt-4o-2024-08-06', object='chat.completion', system_fingerprint='<redacted>', usage=Usage(completion_tokens=31, prompt_tokens=500, total_tokens=531, completion_tokens_details=CompletionTokensDetails(reasoning_tokens=0), prompt_tokens_details={'cached_tokens': 0}), service_tier=None) and tool choice was 'required'.

This PR thus generalizes the allowable finish_reasons when tool_choice is set to "required" (default)

@jamesbraza jamesbraza added the bug Something isn't working label Oct 8, 2024
@jamesbraza jamesbraza self-assigned this Oct 8, 2024
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Oct 8, 2024
@jamesbraza jamesbraza merged commit 941205f into main Oct 9, 2024
6 checks passed
@jamesbraza jamesbraza deleted the fixing-tool-choice-validation branch October 9, 2024 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 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