类 ChatResponse.Builder

java.lang.Object
io.agentscope.core.model.ChatResponse.Builder
封闭类:
ChatResponse

public static class ChatResponse.Builder extends Object
Builder for creating ChatResponse instances.
  • 构造器详细资料

    • Builder

      public Builder()
  • 方法详细资料

    • id

      public ChatResponse.Builder id(String id)
      Sets the response identifier.
      参数:
      id - the unique identifier for this response
      返回:
      this builder instance
    • content

      public ChatResponse.Builder content(List<ContentBlock> content)
      Sets the content blocks for the response.
      参数:
      content - the list of content blocks containing the response content
      返回:
      this builder instance
    • usage

      public ChatResponse.Builder usage(ChatUsage usage)
      Sets the usage information for the response.
      参数:
      usage - the token usage information
      返回:
      this builder instance
    • metadata

      public ChatResponse.Builder metadata(Map<String,Object> metadata)
      Sets the metadata for the response.
      参数:
      metadata - additional metadata from the model provider
      返回:
      this builder instance
    • finishReason

      public ChatResponse.Builder finishReason(String finishReason)
      Sets the finish reason for the response.
      参数:
      finishReason - the finish reason sent by the model provider
      返回:
      this builder instance
    • build

      public ChatResponse build()
      Builds a new ChatResponse instance with the set values.

      If no id was set (or is empty/blank), a random UUID will be generated automatically. This ensures compatibility with LLM providers (like Ollama) that don't return an id field in their API responses.

      返回:
      a new ChatResponse instance