Record Class AnthropicApi.AnthropicMessage

java.lang.Object
java.lang.Record
org.springframework.ai.anthropic.api.AnthropicApi.AnthropicMessage
Record Components:
content - The contents of the message. Can be of one of String or MultiModalContent.
role - The role of the messages author. Could be one of the AnthropicApi.Role types.
Enclosing class:
AnthropicApi

public static record AnthropicApi.AnthropicMessage(List<AnthropicApi.ContentBlock> content, AnthropicApi.Role role) extends Record
Input messages. Our models are trained to operate on alternating user and assistant conversational turns. When creating a new Message, you specify the prior conversational turns with the messages parameter, and the model then generates the next Message in the conversation. Each input message must be an object with a role and content. You can specify a single user-role message, or you can include multiple user and assistant messages. The first message must always use the user role. If the final message uses the assistant role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.
Since:
1.0.0
Author:
Christian Tzolov, Mariusz Bernacki, Thomas Vitale, Jihoon Kim, Alexandros Pappas, Jonghoon Park, Claudio Silva Junior, Filip Hrisafov, Soby Chacko, Austin Dase
  • Constructor Details

  • 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.
    • content

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

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