ToolCall
@JsonInclude(JsonInclude.Include.NON_NULL) public class ToolCall
io/agentscope/core/chat/completions/model/ToolCall.java:53–164以OpenAI 兼容的格式表示工具调用。位于 io.agentscope.core.chat.completions.model 包。核心成员包括 getIndex、setIndex、getId、setId、getType、setType。
Represents a tool call in OpenAI-compatible format.
This DTO is used to serialize tool calls in the conversation context, allowing clients to reconstruct the full conversation history including tool invocations.
Example JSON (non-streaming):
`{
"id": "call_abc123",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"city\":\"Hangzhou\"}"
}
}
`
Example JSON (streaming with index):
`{
"index": 0,
"id": "call_abc123",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"city\":\"Hangzhou\"}"
}
}
`
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
FunctionCall | 类class | 函数调用,与模型服务通信并返回生成或向量化结果。 Represents the function details within a tool call. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public ToolCall() | 初始化 `ToolCall` 实例。 Default constructor for deserialization. |
public ToolCall(String id, String name, String arguments) | 创建新的工具调用。 Creates a new tool call. |
public ToolCall(Integer index, String id, String name, String arguments) | 创建新的工具调用使用索引(用于流式)。 Creates a new tool call with index (for streaming). |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Integer getIndex() | 获取索引。 Returns the index. |
public void setIndex(Integer index) | 设置索引。 Sets the index. |
public String getId() | 获取标识。 Returns the id. |
public void setId(String id) | 设置标识。 Sets the id. |
public String getType() | 获取类型。 Returns the type. |
public void setType(String type) | 设置类型。 Sets the type. |
public FunctionCall getFunction() | 获取函数。 Returns the function. |
public void setFunction(FunctionCall function) | 设置函数。 Sets the function. |
构造器详情Constructor Detail
ToolCall
public ToolCall()
初始化 ToolCall 实例。
Default constructor for deserialization.
io/agentscope/core/chat/completions/model/ToolCall.java:65ToolCall
public ToolCall(String id, String name, String arguments)
创建新的工具调用。
Creates a new tool call.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
id | String | 标识(类型 `String`)。Unique identifier for this tool call |
name | String | 名称(类型 `String`)。Function name |
arguments | String | 参数(类型 `String`)。JSON string of function arguments |
io/agentscope/core/chat/completions/model/ToolCall.java:74–78ToolCall
public ToolCall(Integer index, String id, String name, String arguments)
创建新的工具调用使用索引(用于流式)。
Creates a new tool call with index (for streaming).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
index | Integer | 索引(类型 `Integer`)。Index in the tool_calls array |
id | String | 标识(类型 `String`)。Unique identifier for this tool call |
name | String | 名称(类型 `String`)。Function name |
arguments | String | 参数(类型 `String`)。JSON string of function arguments |
io/agentscope/core/chat/completions/model/ToolCall.java:88–93方法详情Method Detail
getIndex
public Integer getIndex()
获取索引。
Returns the index.
Integerio/agentscope/core/chat/completions/model/ToolCall.java:95–97setIndex
public void setIndex(Integer index)
设置索引。
Sets the index.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
index | Integer | 索引(类型 `Integer`)。The index. |
io/agentscope/core/chat/completions/model/ToolCall.java:99–101getId
public String getId()
获取标识。
Returns the id.
Stringio/agentscope/core/chat/completions/model/ToolCall.java:103–105setId
public void setId(String id)
设置标识。
Sets the id.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
id | String | 标识(类型 `String`)。The id. |
io/agentscope/core/chat/completions/model/ToolCall.java:107–109getType
public String getType()
获取类型。
Returns the type.
Stringio/agentscope/core/chat/completions/model/ToolCall.java:111–113setType
public void setType(String type)
设置类型。
Sets the type.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
type | String | 类型(类型 `String`)。The type. |
io/agentscope/core/chat/completions/model/ToolCall.java:115–117getFunction
public FunctionCall getFunction()
获取函数。
Returns the function.
FunctionCallio/agentscope/core/chat/completions/model/ToolCall.java:119–121setFunction
public void setFunction(FunctionCall function)
设置函数。
Sets the function.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
function | FunctionCall | 函数(类型 `FunctionCall`)。The function. |
io/agentscope/core/chat/completions/model/ToolCall.java:123–125嵌套类详情Nested Class Detail
FunctionCall
public static class FunctionCall函数调用,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.core.chat.completions.model 包。核心成员包括 getName、setName、getArguments、setArguments、FunctionCall。
Represents the function details within a tool call.