类 ChatResponse

java.lang.Object
io.agentscope.core.model.ChatResponse

public class ChatResponse extends Object
Represents a chat completion response from a language model.

This immutable data class contains the response content, usage information, and optional metadata returned by the model after processing a chat request.

  • 构造器详细资料

    • ChatResponse

      public ChatResponse(String id, List<ContentBlock> content, ChatUsage usage, Map<String,Object> metadata, String finishReason)
      Creates a new ChatResponse instance.
      参数:
      id - the unique identifier for this response
      content - the list of content blocks containing the response content
      usage - the token usage information for this response
      metadata - additional metadata from the model provider
      finishReason - the reason for
  • 方法详细资料

    • getId

      public String getId()
      Gets the unique identifier for this response.
      返回:
      the response identifier
    • getContent

      public List<ContentBlock> getContent()
      Gets the content blocks containing the response content.
      返回:
      the list of content blocks
    • getUsage

      public ChatUsage getUsage()
      Gets the token usage information for this response.
      返回:
      the usage information
    • getMetadata

      public Map<String,Object> getMetadata()
      Gets the metadata from the model provider.
      返回:
      the metadata map
    • getFinishReason

      public String getFinishReason()
      Gets the reason the model stopped generating tokens.
      返回:
      the finish reason
    • withId

      public ChatResponse withId(String newId)
      Creates a new instance of ChatResponse with the specified ID, copying all other fields from this instance.
      参数:
      newId - the new identifier
      返回:
      a new ChatResponse instance
    • builder

      public static ChatResponse.Builder builder()
      Creates a new builder for ChatResponse.
      返回:
      a new Builder instance