Record Class AnthropicApi.ContentBlock

java.lang.Object
java.lang.Record
org.springframework.ai.anthropic.api.AnthropicApi.ContentBlock
Record Components:
type - the content type can be "text", "image", "tool_use", "tool_result" or "text_delta".
source - The source of the media content. Applicable for "image" types only.
text - The text of the message. Applicable for "text" types only.
index - The index of the content block. Applicable only for streaming responses.
id - The id of the tool use. Applicable only for tool_use response.
name - The name of the tool use. Applicable only for tool_use response.
input - The input of the tool use. Applicable only for tool_use response.
toolUseId - The id of the tool use. Applicable only for tool_result response.
content - The content of the tool result. Applicable only for tool_result response.
Enclosing class:
AnthropicApi

public static record AnthropicApi.ContentBlock(AnthropicApi.ContentBlock.Type type, AnthropicApi.ContentBlock.Source source, String text, Integer index, String id, String name, Map<String,Object> input, String toolUseId, String content, String signature, String thinking, String data) extends Record
The content block of the message.
  • Constructor Details

    • ContentBlock

      public ContentBlock(String mediaType, String data)
      Create content block
      Parameters:
      mediaType - The media type of the content.
      data - The content data.
    • ContentBlock

      Create content block
      Parameters:
      type - The type of the content.
      source - The source of the content.
    • ContentBlock

      public ContentBlock(AnthropicApi.ContentBlock.Source source)
      Create content block
      Parameters:
      source - The source of the content.
    • ContentBlock

      public ContentBlock(String text)
      Create content block
      Parameters:
      text - The text of the content.
    • ContentBlock

      public ContentBlock(AnthropicApi.ContentBlock.Type type, String toolUseId, String content)
      Create content block
      Parameters:
      type - The type of the content.
      toolUseId - The id of the tool use.
      content - The content of the tool result.
    • ContentBlock

      public ContentBlock(AnthropicApi.ContentBlock.Type type, AnthropicApi.ContentBlock.Source source, String text, Integer index)
      Create content block
      Parameters:
      type - The type of the content.
      source - The source of the content.
      text - The text of the content.
      index - The index of the content block.
    • ContentBlock

      public ContentBlock(AnthropicApi.ContentBlock.Type type, String id, String name, Map<String,Object> input)
      Create content block
      Parameters:
      type - The type of the content.
      id - The id of the tool use.
      name - The name of the tool use.
      input - The input of the tool use.
    • ContentBlock

      public ContentBlock(AnthropicApi.ContentBlock.Type type, AnthropicApi.ContentBlock.Source source, String text, Integer index, String id, String name, Map<String,Object> input, String toolUseId, String content, String signature, String thinking, String data)
      Creates an instance of a ContentBlock record class.
      Parameters:
      type - the value for the type record component
      source - the value for the source record component
      text - the value for the text record component
      index - the value for the index record component
      id - the value for the id record component
      name - the value for the name record component
      input - the value for the input record component
      toolUseId - the value for the toolUseId record component
      content - the value for the content record component
      signature - the value for the signature record component
      thinking - the value for the thinking record component
      data - the value for the data 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.
    • type

      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • source

      Returns the value of the source record component.
      Returns:
      the value of the source record component
    • text

      public String text()
      Returns the value of the text record component.
      Returns:
      the value of the text record component
    • index

      public Integer index()
      Returns the value of the index record component.
      Returns:
      the value of the index record component
    • id

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

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • input

      public Map<String,Object> input()
      Returns the value of the input record component.
      Returns:
      the value of the input record component
    • toolUseId

      public String toolUseId()
      Returns the value of the toolUseId record component.
      Returns:
      the value of the toolUseId record component
    • content

      public String content()
      Returns the value of the content record component.
      Returns:
      the value of the content record component
    • signature

      public String signature()
      Returns the value of the signature record component.
      Returns:
      the value of the signature record component
    • thinking

      public String thinking()
      Returns the value of the thinking record component.
      Returns:
      the value of the thinking record component
    • data

      public String data()
      Returns the value of the data record component.
      Returns:
      the value of the data record component