Skip to content

Initialize the delta tool call fields explicitly #17340

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 7 commits into from
May 12, 2025

Conversation

maxdebayser
Copy link
Contributor

@maxdebayser maxdebayser commented Apr 29, 2025

Fixes #16340
Continuing the work of #16340

Previously the implementation relied on a combination of the default field values being and
model_dump_json(exclude_unset=True). This led to bugs such as the "type" field missing from the response.

The behavior of the OpenAI API is to set the "id" and "type" fields only in the first Delta object.

The purpose of this commit is to make all the places where these fields need to be set explicit.

Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

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 either: Add ready label to the PR or enable auto-merge.

🚀

Previously the implementation relied on a combination
of the default field values being and
`model_dump_json(exclude_unset=True)`. This led to bugs such
as the "type" field missing from the response.

The behavior of the OpenAI API is to set the "id" and "type"
fields only in the first Delta object.

The purpose of this commit is to make all the places
where these fields need to be set explicit.

Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
Co-authored-by: igmainc <igmainc@icloud.com>
@DarkLight1337
Copy link
Member

This looks good to me, let's have @iGmainC verify first though

@maxdebayser
Copy link
Contributor Author

Agreed

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

mergify bot commented Apr 30, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @maxdebayser.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Apr 30, 2025
Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
@mergify mergify bot removed the needs-rebase label Apr 30, 2025
Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
@iGmainC
Copy link
Contributor

iGmainC commented May 2, 2025

This looks good to me, let's have @iGmainC verify first though

OK, I will test it as soon as possible.

The delta too call type can only be set once during the stream

Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
@aarnphm aarnphm self-requested a review May 2, 2025 18:57
Copy link
Collaborator

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

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

Thanks. LGTM

@DarkLight1337
Copy link
Member

Tests are failing though

@maxdebayser
Copy link
Contributor Author

@iGmainC , did you get a chance to test on your side? The CI tests are passing now.

@iGmainC
Copy link
Contributor

iGmainC commented May 12, 2025

@iGmainC , did you get a chance to test on your side? The CI tests are passing now.

I briefly tested my scene and it seemed to be ok.

@DarkLight1337 DarkLight1337 enabled auto-merge (squash) May 12, 2025 11:52
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label May 12, 2025
@DarkLight1337 DarkLight1337 merged commit 05a4324 into vllm-project:main May 12, 2025
56 checks passed
mawong-amd pushed a commit to ROCm/vllm that referenced this pull request May 14, 2025
Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
Co-authored-by: igmainc <igmainc@icloud.com>
zzzyq pushed a commit to zzzyq/vllm that referenced this pull request May 24, 2025
Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
Co-authored-by: igmainc <igmainc@icloud.com>
Signed-off-by: Yuqi Zhang <yuqizhang@google.com>
minpeter pushed a commit to minpeter/vllm that referenced this pull request Jun 24, 2025
Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
Co-authored-by: igmainc <igmainc@icloud.com>
Signed-off-by: minpeter <kali2005611@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend ready ONLY add when PR is ready to merge/full CI is needed tool-calling
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Bug]: Missing "type":"function" in OpenAI-Compatible Streaming Tool Calls with specific tool_choice
4 participants