Record Class ReasoningPart
java.lang.Object
java.lang.Record
org.springframework.ai.chat.messages.part.ReasoningPart
- Record Components:
text- the human-readable reasoning, ornullwhen absentsummary- a provider-supplied summary of the reasoning, ornullpayload- provider data to replay with this part, ornullattributes- free-form attributes, copied and unmodifiable
- All Implemented Interfaces:
MessagePart
public record ReasoningPart(@Nullable String text, @Nullable String summary, @Nullable OpaquePayload payload, Map<String,String> attributes)
extends Record
implements MessagePart
Model reasoning (thinking) that preceded or accompanied the answer.
The provider-neutral text and summary are for display. The
payload() carries what the producing provider requires to be replayed verbatim
(a signature, encrypted content, a thought signature) and is only meaningful to that
provider; see replayableTo(String).
- Since:
- 2.1.0
- Author:
- Christian Tzolov
-
Constructor Summary
ConstructorsConstructorDescriptionReasoningPart(@Nullable String text, @Nullable String summary, @Nullable OpaquePayload payload, Map<String, String> attributes) Creates an instance of aReasoningPartrecord 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 ReasoningPartCreates a plain reasoning part with text only, replayable to any provider.@Nullable OpaquePayloadpayload()Returns the value of thepayloadrecord component.booleanreplayableTo(String provider) Whether this part can be sent to the given provider without losing its payload: true when there is no payload, or when the payload was produced by that provider.@Nullable Stringsummary()Returns the value of thesummaryrecord component.@Nullable Stringtext()Returns the value of thetextrecord 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
-
ReasoningPart
public ReasoningPart(@Nullable String text, @Nullable String summary, @Nullable OpaquePayload payload, Map<String, String> attributes) Creates an instance of aReasoningPartrecord class.- Parameters:
text- the value for thetextrecord componentsummary- the value for thesummaryrecord 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 plain reasoning part with text only, replayable to any provider.- Parameters:
text- the reasoning text- Returns:
- the part
-
replayableTo
Whether this part can be sent to the given provider without losing its payload: true when there is no payload, or when the payload was produced by that provider.- Parameters:
provider- the target provider, for exampleanthropic- Returns:
- whether the part is replayable to the provider
-
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). -
text
Returns the value of thetextrecord component.- Returns:
- the value of the
textrecord component
-
summary
Returns the value of thesummaryrecord component.- Returns:
- the value of the
summaryrecord 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
-