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)
extends Record
The content block of the message.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe source of the media content.static enumThe 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) Creates an instance of aContentBlockrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncontent()Returns the value of thecontentrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.index()Returns the value of theindexrecord component.input()Returns the value of theinputrecord component.name()Returns the value of thenamerecord component.source()Returns the value of thesourcerecord component.text()Returns the value of thetextrecord component.Returns the value of thetoolUseIdrecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord 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) Creates an instance of aContentBlockrecord class.- Parameters:
type- the value for thetyperecord componentsource- the value for thesourcerecord componenttext- the value for thetextrecord componentindex- the value for theindexrecord componentid- the value for theidrecord componentname- the value for thenamerecord componentinput- the value for theinputrecord componenttoolUseId- the value for thetoolUseIdrecord componentcontent- the value for thecontentrecord 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 thetyperecord component.- Returns:
- the value of the
typerecord component
-
source
Returns the value of thesourcerecord component.- Returns:
- the value of the
sourcerecord component
-
text
Returns the value of thetextrecord component.- Returns:
- the value of the
textrecord component
-
index
Returns the value of theindexrecord component.- Returns:
- the value of the
indexrecord component
-
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
input
Returns the value of theinputrecord component.- Returns:
- the value of the
inputrecord component
-
toolUseId
Returns the value of thetoolUseIdrecord component.- Returns:
- the value of the
toolUseIdrecord component
-
content
Returns the value of thecontentrecord component.- Returns:
- the value of the
contentrecord component
-