Record Class ToolCallPart
java.lang.Object
java.lang.Record
org.springframework.ai.chat.messages.part.ToolCallPart
- Record Components:
toolCall- the tool callpayload- provider data to replay with this part, ornullattributes- free-form attributes, copied and unmodifiable
- All Implemented Interfaces:
MessagePart
public record ToolCallPart(AssistantMessage.ToolCall toolCall, @Nullable OpaquePayload payload, Map<String,String> attributes)
extends Record
implements MessagePart
A tool call requested by the model.
The payload() slot exists on tool calls because some providers attach their
reasoning token to the call rather than to a ReasoningPart (for example a
Gemini thought_signature).
- Since:
- 2.1.0
- Author:
- Christian Tzolov
-
Constructor Summary
ConstructorsConstructorDescriptionToolCallPart(AssistantMessage.ToolCall toolCall, @Nullable OpaquePayload payload, Map<String, String> attributes) Creates an instance of aToolCallPartrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theattributesrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static ToolCallPartof(AssistantMessage.ToolCall toolCall) Creates a tool call part without payload or attributes.@Nullable OpaquePayloadpayload()Returns the value of thepayloadrecord component.toolCall()Returns the value of thetoolCallrecord component.final StringtoString()Returns a string representation of this record class.withAttributes(Map<String, String> attributes) Returns a copy of this part with the given attributes replacing the current ones.
-
Constructor Details
-
ToolCallPart
public ToolCallPart(AssistantMessage.ToolCall toolCall, @Nullable OpaquePayload payload, Map<String, String> attributes) Creates an instance of aToolCallPartrecord class.- Parameters:
toolCall- the value for thetoolCallrecord componentpayload- the value for thepayloadrecord componentattributes- the value for theattributesrecord component
-
-
Method Details
-
withAttributes
Description copied from interface:MessagePartReturns a copy of this part with the given attributes replacing the current ones. All other components are unchanged.- Specified by:
withAttributesin interfaceMessagePart- Parameters:
attributes- the new attributes, copied- Returns:
- the copy
-
of
Creates a tool call part without payload or attributes.- Parameters:
toolCall- the tool call- Returns:
- the part
-
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). -
toolCall
Returns the value of thetoolCallrecord component.- Returns:
- the value of the
toolCallrecord component
-
payload
Returns the value of thepayloadrecord component.- Specified by:
payloadin interfaceMessagePart- Returns:
- the value of the
payloadrecord component
-
attributes
Returns the value of theattributesrecord component.- Specified by:
attributesin interfaceMessagePart- Returns:
- the value of the
attributesrecord component
-