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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
The source of the media content.static enum
The ContentBlock type. -
Constructor Summary
ConstructorsConstructorDescriptionContentBlock
(String text) Create content blockContentBlock
(String mediaType, String data) Create content blockCreate content blockContentBlock
(AnthropicApi.ContentBlock.Type type, String toolUseId, String content) Create content blockContentBlock
(AnthropicApi.ContentBlock.Type type, String id, String name, Map<String, Object> input) Create content blockCreate content blockContentBlock
(AnthropicApi.ContentBlock.Type type, AnthropicApi.ContentBlock.Source source, String text, Integer index) Create content blockContentBlock
(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 aContentBlock
record class. -
Method Summary
Modifier and TypeMethodDescriptioncontent()
Returns the value of thecontent
record component.data()
Returns the value of thedata
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.id()
Returns the value of theid
record component.index()
Returns the value of theindex
record component.input()
Returns the value of theinput
record component.name()
Returns the value of thename
record component.Returns the value of thesignature
record component.source()
Returns the value of thesource
record component.text()
Returns the value of thetext
record component.thinking()
Returns the value of thethinking
record component.Returns the value of thetoolUseId
record component.final String
toString()
Returns a string representation of this record class.type()
Returns the value of thetype
record component.
-
Constructor Details
-
ContentBlock
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
Create content block- Parameters:
source
- The source of the content.
-
ContentBlock
Create content block- Parameters:
text
- The text of the content.
-
ContentBlock
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 aContentBlock
record class.- Parameters:
type
- the value for thetype
record componentsource
- the value for thesource
record componenttext
- the value for thetext
record componentindex
- the value for theindex
record componentid
- the value for theid
record componentname
- the value for thename
record componentinput
- the value for theinput
record componenttoolUseId
- the value for thetoolUseId
record componentcontent
- the value for thecontent
record componentsignature
- the value for thesignature
record componentthinking
- the value for thethinking
record componentdata
- the value for thedata
record component
-
-
Method Details
-
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. -
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. -
equals
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 withObjects::equals(Object,Object)
. -
type
Returns the value of thetype
record component.- Returns:
- the value of the
type
record component
-
source
Returns the value of thesource
record component.- Returns:
- the value of the
source
record component
-
text
Returns the value of thetext
record component.- Returns:
- the value of the
text
record component
-
index
Returns the value of theindex
record component.- Returns:
- the value of the
index
record component
-
id
Returns the value of theid
record component.- Returns:
- the value of the
id
record component
-
name
Returns the value of thename
record component.- Returns:
- the value of the
name
record component
-
input
Returns the value of theinput
record component.- Returns:
- the value of the
input
record component
-
toolUseId
Returns the value of thetoolUseId
record component.- Returns:
- the value of the
toolUseId
record component
-
content
Returns the value of thecontent
record component.- Returns:
- the value of the
content
record component
-
signature
Returns the value of thesignature
record component.- Returns:
- the value of the
signature
record component
-
thinking
Returns the value of thethinking
record component.- Returns:
- the value of the
thinking
record component
-
data
Returns the value of thedata
record component.- Returns:
- the value of the
data
record component
-