llama-stack-mirror/llama_stack/providers
Ben Browning e2960e9e44 fix: inference providers still using tools with tool_choice="none"
In our OpenAI API verification tests, some providers were still calling
tools even when `tool_choice="none"` was passed in the chat completion
requests. Because they aren't all respecting `tool_choice` properly,
this adjusts our routing implementation to remove the `tools` and
`tool_choice` from the request if `tool_choice="none"` is passed in so
that it does not attempt to call any of those tools. Adjusting this in
the router fixes this across all providers.

This also cleans up the non-streaming chat completion responses for tools,
ensuring it returns `None` instead of an empty list when there are no
tool calls, to exactly match the OpenAI API responses in that case.

I observed existing failures in our OpenAI API verification suite -
see
https://github.com/bbrowning/llama-stack-tests/blob/main/openai-api-verification/2025-04-27.md#together-llama-stack
for the failing `test_chat_*_tool_choice_none` tests. All streaming
and non-streaming variants were failing across all 3 tested models.

After this change, all of those 6 failing tests are now passing with
no regression in the other tests.

I verified this via:

```
llama stack run --image-type venv \
  tests/verifications/openai-api-verification-run.yaml
```

```
python -m pytest -s -v \
  'tests/verifications/openai_api/test_chat_completion.py' \
  --provider=together-llama-stack
```

The entire verification suite is not 100% on together.ai yet, but it's
getting closer.

This also increased the pass rate for fireworks.ai, and did not regress
the groq or openai tests at all.

Signed-off-by: Ben Browning <bbrownin@redhat.com>
2025-04-30 13:27:28 -04:00
..
inline chore: Remove zero-width space characters from OTEL service name env var defaults (#2060) 2025-04-30 17:56:46 +02:00
registry feat: add api.llama provider, llama-guard-4 model (#2058) 2025-04-29 10:07:41 -07:00
remote fix: inference providers still using tools with tool_choice="none" 2025-04-30 13:27:28 -04:00
tests refactor: move all llama code to models/llama out of meta reference (#1887) 2025-04-07 15:03:58 -07:00
utils feat: add api.llama provider, llama-guard-4 model (#2058) 2025-04-29 10:07:41 -07:00
__init__.py API Updates (#73) 2024-09-17 19:51:35 -07:00
datatypes.py feat: add health to all providers through providers endpoint (#1418) 2025-04-14 11:59:36 +02:00