Class ChatCompletionsResponse
java.lang.Object
io.agentscope.core.chat.completions.model.ChatCompletionsResponse
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
Nested ClassesModifier and TypeClassDescriptionstatic classToken usage statistics following OpenAI's format. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlonggetId()getModel()getUsage()voidsetChoices(List<ChatChoice> choices) voidsetCreated(long created) voidvoidvoidvoid
-
Constructor Details
-
ChatCompletionsResponse
public ChatCompletionsResponse()
-
-
Method Details
-
getId
-
setId
-
getObject
-
setObject
-
getCreated
public long getCreated() -
setCreated
public void setCreated(long created) -
getModel
-
setModel
-
getChoices
-
setChoices
-
getUsage
-
setUsage
-