Record Class AnthropicApi.ChatCompletionResponse

java.lang.Object
java.lang.Record
org.springframework.ai.anthropic.api.AnthropicApi.ChatCompletionResponse
Record Components:
id - Unique object identifier. The format and length of IDs may change over time.
type - Object type. For Messages, this is always "message".
role - Conversational role of the generated message. This will always be "assistant".
content - Content generated by the model. This is an array of content blocks.
model - The model that handled the request.
stopReason - The reason the model stopped generating tokens. This will be one of "end_turn", "max_tokens", "stop_sequence", "tool_use", or "timeout".
stopSequence - Which custom stop sequence was generated, if any.
usage - Input and output token usage.
Enclosing class:
AnthropicApi

public static record AnthropicApi.ChatCompletionResponse(String id, String type, AnthropicApi.Role role, List<AnthropicApi.ContentBlock> content, String model, String stopReason, String stopSequence, AnthropicApi.Usage usage) extends Record
Chat completion response object.
  • Constructor Details

    • ChatCompletionResponse

      public ChatCompletionResponse(String id, String type, AnthropicApi.Role role, List<AnthropicApi.ContentBlock> content, String model, String stopReason, String stopSequence, AnthropicApi.Usage usage)
      Creates an instance of a ChatCompletionResponse record class.
      Parameters:
      id - the value for the id record component
      type - the value for the type record component
      role - the value for the role record component
      content - the value for the content record component
      model - the value for the model record component
      stopReason - the value for the stopReason record component
      stopSequence - the value for the stopSequence record component
      usage - the value for the usage record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • type

      public String type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • role

      public AnthropicApi.Role role()
      Returns the value of the role record component.
      Returns:
      the value of the role record component
    • content

      public List<AnthropicApi.ContentBlock> content()
      Returns the value of the content record component.
      Returns:
      the value of the content record component
    • model

      public String model()
      Returns the value of the model record component.
      Returns:
      the value of the model record component
    • stopReason

      public String stopReason()
      Returns the value of the stopReason record component.
      Returns:
      the value of the stopReason record component
    • stopSequence

      public String stopSequence()
      Returns the value of the stopSequence record component.
      Returns:
      the value of the stopSequence record component
    • usage

      public AnthropicApi.Usage usage()
      Returns the value of the usage record component.
      Returns:
      the value of the usage record component