ToolChoice
public sealed interface ToolChoice permits ToolChoice.Auto, ToolChoice.None, ToolChoice.Required, ToolChoice.Specific
io/agentscope/core/model/ToolChoice.java:45–84表示工具选项行为用于大模型模型调用。位于 io.agentscope.core.model 包。
Represents the tool choice behavior for LLM model calls.
This sealed interface defines how the model should handle tool calling:
-
Auto- Let the model decide whether and which tools to call (default) -
None- Prevent the model from calling any tools -
Required- Force the model to call at least one tool (model chooses which) -
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();
`
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Auto | 记录record | 承载 Auto数据的记录类型。 Auto mode: Let the model decide whether and which tools to call. |
None | 记录record | 承载 None数据的记录类型。 None mode: Prevent the model from calling any tools. |
Required | 记录record | 承载必填数据的记录类型。 Required mode: Force the model to call at least one tool. |
Specific | 记录record | 承载特定数据的记录类型。 Specific mode: Force the model to call a specific tool by name. |
嵌套类详情Nested Class Detail
Auto
record Auto() implements ToolChoice承载 Auto数据的记录类型。位于 io.agentscope.core.model 包,实现 ToolChoice。
Auto mode: Let the model decide whether and which tools to call. This is the default behavior when toolChoice is not specified.
None
record None() implements ToolChoice承载 None数据的记录类型。位于 io.agentscope.core.model 包,实现 ToolChoice。
None mode: Prevent the model from calling any tools. The model will respond with text only.
Required
record Required() implements ToolChoice承载必填数据的记录类型。位于 io.agentscope.core.model 包,实现 ToolChoice。
Required mode: Force the model to call at least one tool. The model chooses which tool(s) to call based on the context.
Specific
record Specific(String toolName) implements ToolChoice承载特定数据的记录类型。位于 io.agentscope.core.model 包,实现 ToolChoice。核心成员包括 toolName、Specific。
Specific mode: Force the model to call a specific tool by name.