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

[BugFix] Fix tool call finish reason in streaming case #9209

Merged
merged 7 commits into from
Oct 12, 2024

Conversation

maxdebayser
Copy link
Contributor

When a named function is passed to tool_choice with streaming the finish_reason was "stop" instead of "tool_calls".

When a named function is passed to tool_choice with streaming the
finish_reason was "stop" instead of "tool_calls".

Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
Copy link

github-actions bot commented Oct 9, 2024

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

@maxdebayser
Copy link
Contributor Author

cc: @njhill @tjohnson31415

maxdebayser and others added 2 commits October 10, 2024 09:52
@tjohnson31415
Copy link
Contributor

tjohnson31415 commented Oct 10, 2024

Actually, this behavior may be expected in the OpenAI spec 🤔

Check if the model has made a tool_call. This is the case either if the "finish_reason" is "tool_calls" or if the "finish_reason" is "stop" and our API request had forced a function call
...
This handles the edge case where if we forced the model to call one of our functions, the finish_reason will actually be "stop" instead of "tool_calls"

REF: https://platform.openai.com/docs/guides/function-calling/edge-cases

Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
@maxdebayser
Copy link
Contributor Author

Actually, this behavior may be expected in the OpenAI spec

Yeah, I'll test to see what OpenAI returns. If that is the case, then it's the non-streaming case that is inconsistent.

@maxdebayser
Copy link
Contributor Author

@tjohnson31415 , you're right. I've tested with gpt4 on the OpenAI platform and the behavior is as follows:

OpenAI    
  named function auto
unary stop tool_calls
stream stop tool_calls

So actually the non-streaming case for named function needs to be changed to return stop instead of tool_calls

Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
@njhill njhill added the ready ONLY add when PR is ready to merge/full CI is needed label Oct 11, 2024
@njhill njhill changed the title Fix tool call finish reason in streaming case [BugFix] Fix tool call finish reason in streaming case Oct 11, 2024
Copy link
Member

@njhill njhill left a comment

Choose a reason for hiding this comment

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

Thanks @maxdebayser!

@njhill njhill merged commit ec10cb8 into vllm-project:main Oct 12, 2024
65 checks passed
Alvant pushed a commit to compressa-ai/vllm that referenced this pull request Oct 26, 2024
…9209)

Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
Signed-off-by: Alvant <alvasian@yandex.ru>
garg-amit pushed a commit to garg-amit/vllm that referenced this pull request Oct 28, 2024
…9209)

Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
Signed-off-by: Amit Garg <mitgarg17495@gmail.com>
sumitd2 pushed a commit to sumitd2/vllm that referenced this pull request Nov 14, 2024
…9209)

Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
Signed-off-by: Sumit Dubey <sumit.dubey2@ibm.com>
KuntaiDu pushed a commit to KuntaiDu/vllm that referenced this pull request Nov 20, 2024
…9209)

Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
mfournioux pushed a commit to mfournioux/vllm that referenced this pull request Nov 20, 2024
…9209)

Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
Signed-off-by: Maxime Fournioux <55544262+mfournioux@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants