Add `tool_choice` parameter to `ChatCompletionClient` `create` and `create_stream` methods (#6697)
## Summary Implements the `tool_choice` parameter for `ChatCompletionClient` interface as requested in #6696. This allows users to restrict which tools the model can choose from when multiple tools are available. ## Changes ### Core Interface - Core Interface: Added `tool_choice: Tool | Literal["auto", "required", "none"] = "auto"` parameter to `ChatCompletionClient.create()` and `create_stream()` methods - Model Implementations: Updated client implementations to support the new parameter, for now, only the following model clients are supported: - OpenAI - Anthropic - Azure AI - Ollama - `LlamaCppChatCompletionClient` currently not supported Features - "auto" (default): Let the model choose whether to use tools, when there is no tool, it has no effect. - "required": Force the model to use at least one tool - "none": Disable tool usage completely - Tool object: Force the model to use a specific tool --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
C
Copilot committed
c150f850446974c12f64fbcd896f8868daa9009b
Parent: 6f15270
Committed by GitHub <noreply@github.com>
on 6/30/2025, 5:15:28 AM