类class
agentscope.toolToolChoice
class ToolChoice(BaseModel)
源码Source
agentscope/tool/_types.py:178–203工具选项配置。位于 agentscope.tool 包。
The tool choice configuration. Declared in agentscope.tool.
属性摘要Attribute Summary
| 属性Attribute | 类型Type | 说明Description | 值Value |
|---|---|---|---|
mode | Literal['auto', 'none', 'required'] | str | 模式字段。 The tool choice mode. Supports:
* ``"auto"`` – the model decides whether to call a tool.
* ``"none"`` – the model must not call any tool.
* ``"required"`` – the model must call at least one tool.
* ``str`` (a tool name) – the model **must** call exactly that
tool (forced single-tool call). The name is validated against
``tools`` (if provided) or against the full tools list passed to
the model. | — |
tools | list[str] | None | 工具字段。 An optional list of tool names. When specified, the tool
schemas forwarded to the model are filtered to only those tools.
This also acts as a validation whitelist for ``mode`` when it
is a specific tool name (str): the name must appear in this
list. Prefer using ``mode=<tool_name>`` (str) over
``tools=["<tool_name>"]`` when the goal is a forced single-tool
call without changing the available tool set, as the former
avoids schema-list changes that would invalidate prompt caches. | None |
属性详情Attribute Detail
mode
Literal['auto', 'none', 'required'] | str模式字段。声明为 Literal['auto', 'none', 'required'] | str。
The tool choice mode. Supports:
"auto"– the model decides whether to call a tool."none"– the model must not call any tool."required"– the model must call at least one tool.str(a tool name) – the model must call exactly that tool (forced single-tool call). The name is validated againsttools(if provided) or against the full tools list passed to the model.
源码Source
agentscope/tool/_types.py:202tools
list[str] | None = None工具字段。声明为 list[str] | None。
An optional list of tool names. When specified, the tool
schemas forwarded to the model are filtered to only those tools.
This also acts as a validation whitelist for mode when it
is a specific tool name (str): the name must appear in this
list. Prefer using mode=<tool_name> (str) over
tools=["<tool_name>"] when the goal is a forced single-tool
call without changing the available tool set, as the former
avoids schema-list changes that would invalidate prompt caches.
源码Source
agentscope/tool/_types.py:203