接口 ToolChoice
public sealed interface ToolChoice
permits ToolChoice.Auto, ToolChoice.None, ToolChoice.Required, ToolChoice.Specific
Represents the tool choice behavior for LLM model calls.
This sealed interface defines how the model should handle tool calling:
ToolChoice.Auto- Let the model decide whether and which tools to call (default)ToolChoice.None- Prevent the model from calling any toolsToolChoice.Required- Force the model to call at least one tool (model chooses which)ToolChoice.Specific- Force the model to call a specific tool by name
Usage Example:
// Force model to call a specific tool
GenerateOptions options = GenerateOptions.builder()
.toolChoice(new ToolChoice.Specific("generate_response"))
.build();
// Let model decide (default)
GenerateOptions options = GenerateOptions.builder()
.toolChoice(new ToolChoice.Auto())
.build();
- 另请参阅:
-
嵌套类概要
嵌套类修饰符和类型接口说明static final recordAuto mode: Let the model decide whether and which tools to call.static final recordNone mode: Prevent the model from calling any tools.static final recordRequired mode: Force the model to call at least one tool.static final recordSpecific mode: Force the model to call a specific tool by name.