ChatCompletionsResponse
@JsonInclude(JsonInclude.Include.NON_NULL) public class ChatCompletionsResponse
io/agentscope/core/chat/completions/model/ChatCompletionsResponse.java:86–207用于聊天补全 HTTP API的响应负载。位于 io.agentscope.core.chat.completions.model 包。核心成员包括 getId、setId、getObject、setObject、getCreated、setCreated。
Response payload for the Chat Completions HTTP API.
This response is 100% compatible with OpenAI's Chat Completions API format. All fields follow the official OpenAI specification exactly.
Standard Response:
`{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1234567890,
"model": "gpt-4",
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": "Hello!"},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 5,
"total_tokens": 15
}
}
`
Response with Tool Calls:
When the assistant calls tools:
`{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [{
"id": "call_abc",
"type": "function",
"function": {"name": "get_weather", "arguments": "{\"city\":\"Hangzhou\"}"}
}]
},
"finish_reason": "tool_calls"
}],
"usage": {...}
}
`
Stateless Client Responsibility:
The client must:
-
Append the assistant message from response to their conversation history
-
If tool_calls present, execute tools and append tool result messages
-
Send the complete history in the next request
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Usage | 类class | 用量,与模型服务通信并返回生成或向量化结果。 Token usage statistics following OpenAI's format. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String getId() | 获取标识。 Returns the id. |
public void setId(String id) | 设置标识。 Sets the id. |
public String getObject() | 获取对象。 Returns the object. |
public void setObject(String object) | 设置对象。 Sets the object. |
public long getCreated() | 获取已创建。 Returns the created. |
public void setCreated(long created) | 设置已创建。 Sets the created. |
public String getModel() | 获取模型。 Returns the model. |
public void setModel(String model) | 设置模型。 Sets the model. |
public List<ChatChoice> getChoices() | 获取 `getChoices`。 Returns the choices. |
public void setChoices(List<ChatChoice> choices) | 设置 `setChoices`。 Sets the choices. |
public Usage getUsage() | 获取用量。 Returns the usage. |
public void setUsage(Usage usage) | 设置用量。 Sets the usage. |
方法详情Method Detail
getId
public String getId()
获取标识。
Returns the id.
Stringio/agentscope/core/chat/completions/model/ChatCompletionsResponse.java:107–109setId
public void setId(String id)
设置标识。
Sets the id.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
id | String | 标识(类型 `String`)。The id. |
io/agentscope/core/chat/completions/model/ChatCompletionsResponse.java:111–113getObject
public String getObject()
获取对象。
Returns the object.
Stringio/agentscope/core/chat/completions/model/ChatCompletionsResponse.java:115–117setObject
public void setObject(String object)
设置对象。
Sets the object.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
object | String | 对象(类型 `String`)。The object. |
io/agentscope/core/chat/completions/model/ChatCompletionsResponse.java:119–121getCreated
public long getCreated()
获取已创建。
Returns the created.
longio/agentscope/core/chat/completions/model/ChatCompletionsResponse.java:123–125setCreated
public void setCreated(long created)
设置已创建。
Sets the created.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
created | long | 已创建(类型 `long`)。The created. |
io/agentscope/core/chat/completions/model/ChatCompletionsResponse.java:127–129getModel
public String getModel()
获取模型。
Returns the model.
Stringio/agentscope/core/chat/completions/model/ChatCompletionsResponse.java:131–133setModel
public void setModel(String model)
设置模型。
Sets the model.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
model | String | 模型实例(类型 `String`)。The model. |
io/agentscope/core/chat/completions/model/ChatCompletionsResponse.java:135–137getChoices
public List<ChatChoice> getChoices()
获取 getChoices。
Returns the choices.
List<ChatChoice>io/agentscope/core/chat/completions/model/ChatCompletionsResponse.java:139–141setChoices
public void setChoices(List<ChatChoice> choices)
设置 setChoices。
Sets the choices.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
choices | List<ChatChoice> | choices(类型 `List`)。The choices. |
io/agentscope/core/chat/completions/model/ChatCompletionsResponse.java:143–145getUsage
public Usage getUsage()
获取用量。
Returns the usage.
Usageio/agentscope/core/chat/completions/model/ChatCompletionsResponse.java:147–149setUsage
public void setUsage(Usage usage)
设置用量。
Sets the usage.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
usage | Usage | 用量(类型 `Usage`)。The usage. |
io/agentscope/core/chat/completions/model/ChatCompletionsResponse.java:151–153嵌套类详情Nested Class Detail
Usage
@JsonInclude(JsonInclude.Include.NON_NULL) public static class Usage用量,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.core.chat.completions.model 包。核心成员包括 getPromptTokens、setPromptTokens、getCompletionTokens、setCompletionTokens、getTotalTokens、setTotalTokens。
Token usage statistics following OpenAI's format.
All fields use snake_case per OpenAI specification.