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

[Feature]: Allow setting tool_choice="none" in LLM calls if the OpenAI comaptible vllm server is started with --enable-auto-tool-choice #9426

Open
1 task done
deheim opened this issue Oct 16, 2024 · 3 comments

Comments

@deheim
Copy link

deheim commented Oct 16, 2024

🚀 The feature, motivation and pitch

Apparently, when starting the (OpenAI compatible) vllm server with the option --enable-auto-tool-choice to handle function calls, it is not possible to prevent tool calls when calling the model.

According to the OpenAI API, this should be possible by setting tool_choice='none'. However, setting tool_choice to "none" seems to be not yet supported by vllm.

Currently, an ValueError is thrown:
Call:

client=OpenAI(...)
completion = client.chat.completions.create(
    messages=[
        {"role": "user", "content": "Write a poem"}],
    model="meta-llama-3.1",
    tool_choice='none'
)

Error Message:
openai.BadRequestError: Error code: 400 - {'object': 'error', 'message': "[{'type': 'value_error', 'loc': ('body',), 'msg': 'Value error, When using `tool_choice`, `tools` must be set.', 'input': {'messages': [{'role': 'user', 'content': 'Write a poem'}], 'model': 'meta-llama-3.1', 'tool_choice': 'none'}, 'ctx': {'error': ValueError('When using `tool_choice`, `tools` must be set.')}}]", 'type': 'BadRequestError', 'param': None, 'code': 400}

Alternatives

The only alternative would be hosting two models in parallel. One for function calls and one for getting outputs without function calls which is not really practicable.

Additional context

No response

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.
@laserkelvin
Copy link

laserkelvin commented Jan 14, 2025

There's since been another related issue, #10526.

IMO the current issue and #10526 are not really feature requests but more bugs: trying to use vLLM served models for downstream applications is essentially incompatible when the same functionality works seamlessly on other serving frameworks like ollama. When agents are allowed to choose to not use a tool, as per the OpenAI spec, we need this supported so that workflows/systems don't break when trying to migrate from ollama to vLLM.

I'm not sure what would get this issue triaged - looking at #8568 it doesn't seem like it would take a lot. Would the maintainers be open to a PR for this?

@laserkelvin
Copy link

Actually, I think I've made a mistake: #10000 seems to actually address the issue @deheim outlined, and the exception message being returned by vLLM as of 0.6.6.post1 reflects this:

'Value error, `tool_choice` must either be a named tool, "auto", or "none".

So nominally "none" is supported. My previous comment stands in that tool usage is still not up to OpenAI API specification (I actually need "required", as mentioned in #10526, not "none"). I'm leaving the earlier comment in case others stumble on this.

@deheim
Copy link
Author

deheim commented Jan 15, 2025

My initial post refered to Version v0.6.3. Maybe already some changes have been made such that tool_choice "none" is now already supported. I can try it out later.

Having the option to set it to "required" would be, however, also nice, I agree.

But yes maybe the classification as a bug is more appropriate since the error message for other values for tool choice explicitly says that tool_choice none is a valid value. I will update it after my tests with the most recent vllm version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants