Class ChatCompletionsResponse

java.lang.Object
io.agentscope.core.chat.completions.model.ChatCompletionsResponse

public class ChatCompletionsResponse extends Object
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:

  1. Append the assistant message from response to their conversation history
  2. If tool_calls present, execute tools and append tool result messages
  3. Send the complete history in the next request
  • Constructor Details

    • ChatCompletionsResponse

      public ChatCompletionsResponse()
  • Method Details