接口 ToolChoice

所有已知实现类:
ToolChoice.Auto, ToolChoice.None, ToolChoice.Required, ToolChoice.Specific

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:

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 record 
    Auto mode: Let the model decide whether and which tools to call.
    static final record 
    None mode: Prevent the model from calling any tools.
    static final record 
    Required mode: Force the model to call at least one tool.
    static final record 
    Specific mode: Force the model to call a specific tool by name.