Skip to content

[Llama 3.1] Currently only named tools are supported error when using it for llama 3.1 when not setting toolChoice or using toolChoice: 'auto' #2503

Open
@vishalsaugat

Description

@vishalsaugat

Description

I am using llama3.1 model using @ai-sdk/openai package.
I get this error

{"object":"error","message":"[{'type': 'value_error', 'loc': ('body',), 'msg': 'Value error, Currently only named tools are supported.',.........

when using 'toolchoice': 'auto' in streamUI or not set it at all.
On reading further I found out that llama doesnt support "tool_choice": "auto" parameter in its API. If its set to null it automatically gets converted to auto.
https://github.com/vercel/ai/blob/f7a94535f1d8b8a6f4179d7f5cd762389ef6de4b/packages/core/core/prompt/prepare-tools-and-tool-choice.ts#L37C21-L37C25

Solution: - support null as parameter which doesnt send tool-choice to Llama or some other models API

Code example

{"object":"error","message":"[{'type': 'value_error', 'loc': ('body',), 'msg': 'Value error, Currently only named tools are supported.',
```

### Additional context

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocsImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions