Skip to content

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

Open
@deheim

Description

🚀 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.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions