类class
agentscope.toolToolResponse
class ToolResponse(BaseModel)
源码Source
agentscope/tool/_response.py:51–178ToolResponse 封装一次工具调用的内容块、状态与元数据,是 ToolChunk 流的最终结果。位于 agentscope.tool 包。核心成员包括 append_chunk。
The tool response from a tool execution, which contains the completed tool result (compared to ToolChunk). Declared in agentscope.tool.
属性摘要Attribute Summary
| 属性Attribute | 类型Type | 说明Description | 值Value |
|---|---|---|---|
content | List[TextBlock | DataBlock] | 工具返回的内容块列表。 | Field(default_factory=list) |
state | Literal[ToolResultState.ERROR, ToolResultState.DENIED, ToolResultState.INTERRUPTED, ToolResultState.SUCCESS] | 工具执行状态,例如成功、失败或中断。 | ToolResultState.SUCCESS |
metadata | dict | 工具附加的元数据。 | Field(default_factory=dict) |
id | str | 标识字段。 | Field(default_factory=_generate_id) |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
def append_chunk(chunk: ToolChunk) -> Self | 追加分块。 Append a tool chunk to the current tool response, accumulate the data blocks and update the state and metadata. |
属性详情Attribute Detail
content
List[TextBlock | DataBlock] = Field(default_factory=list)内容字段。声明为 List[TextBlock | DataBlock]。
The content field.
源码Source
agentscope/tool/_response.py:55state
Literal[ToolResultState.ERROR, ToolResultState.DENIED, ToolResultState.INTERRUPTED, ToolResultState.SUCCESS] = ToolResultState.SUCCESS状态字段。声明为 Literal[ToolResultState.ERROR, ToolResultState.DENIED, ToolResultState.INTERRUPTED, ToolResultState.SUCCESS]。
The state field.
源码Source
agentscope/tool/_response.py:59metadata
dict = Field(default_factory=dict)元数据字段。声明为 dict。
The metadata field.
源码Source
agentscope/tool/_response.py:67id
str = Field(default_factory=_generate_id)标识字段。声明为 str。
The id field.
源码Source
agentscope/tool/_response.py:71方法详情Method Detail
append_chunk
def append_chunk(chunk: ToolChunk) -> Self
追加分块。
Append a tool chunk to the current tool response, accumulate the data blocks and update the state and metadata.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
chunk | ToolChunk | 分块(类型 `ToolChunk`)。The chunk. |
Self
返回自身。Returns self.
源码Source
agentscope/tool/_response.py:74–178