AS AgentScopeAPI 手册 / API Reference

ToolChoice

public sealed interface ToolChoice permits ToolChoice.Auto, ToolChoice.None, ToolChoice.Required, ToolChoice.Specific
源码Source 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.

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.