AS AgentScopeAPI 手册 / API Reference

ToolCall

@JsonInclude(JsonInclude.Include.NON_NULL) public class ToolCall
源码Source 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.

源码Source io/agentscope/core/chat/completions/model/ToolCall.java:65

ToolCall

public ToolCall(String id, String name, String arguments)

创建新的工具调用。

Creates a new tool call.

参数Parameters
名称Name类型Type说明Description
idString标识(类型 `String`)。Unique identifier for this tool call
nameString名称(类型 `String`)。Function name
argumentsString参数(类型 `String`)。JSON string of function arguments
源码Source io/agentscope/core/chat/completions/model/ToolCall.java:74–78

ToolCall

public ToolCall(Integer index, String id, String name, String arguments)

创建新的工具调用使用索引(用于流式)。

Creates a new tool call with index (for streaming).

参数Parameters
名称Name类型Type说明Description
indexInteger索引(类型 `Integer`)。Index in the tool_calls array
idString标识(类型 `String`)。Unique identifier for this tool call
nameString名称(类型 `String`)。Function name
argumentsString参数(类型 `String`)。JSON string of function arguments
源码Source io/agentscope/core/chat/completions/model/ToolCall.java:88–93

方法详情Method Detail

getIndex

public Integer getIndex()

获取索引。

Returns the index.

返回Returns Integer
返回数值结果。Returns a numeric result.
源码Source io/agentscope/core/chat/completions/model/ToolCall.java:95–97

setIndex

public void setIndex(Integer index)

设置索引。

Sets the index.

参数Parameters
名称Name类型Type说明Description
indexInteger索引(类型 `Integer`)。The index.
源码Source io/agentscope/core/chat/completions/model/ToolCall.java:99–101

getId

public String getId()

获取标识。

Returns the id.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/chat/completions/model/ToolCall.java:103–105

setId

public void setId(String id)

设置标识。

Sets the id.

参数Parameters
名称Name类型Type说明Description
idString标识(类型 `String`)。The id.
源码Source io/agentscope/core/chat/completions/model/ToolCall.java:107–109

getType

public String getType()

获取类型。

Returns the type.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/chat/completions/model/ToolCall.java:111–113

setType

public void setType(String type)

设置类型。

Sets the type.

参数Parameters
名称Name类型Type说明Description
typeString类型(类型 `String`)。The type.
源码Source io/agentscope/core/chat/completions/model/ToolCall.java:115–117

getFunction

public FunctionCall getFunction()

获取函数。

Returns the function.

返回Returns FunctionCall
返回FunctionCall。Returns function call.
源码Source io/agentscope/core/chat/completions/model/ToolCall.java:119–121

setFunction

public void setFunction(FunctionCall function)

设置函数。

Sets the function.

参数Parameters
名称Name类型Type说明Description
functionFunctionCall函数(类型 `FunctionCall`)。The function.
源码Source 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.

基于官方固定版本源码静态生成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.