Record Class UnknownPart

java.lang.Object
java.lang.Record
org.springframework.ai.chat.messages.part.UnknownPart
Record Components:
provider - who produced the part
kind - the producer's own discriminator, for example server_tool_use
rawJson - the part exactly as received
payload - provider data to replay with this part, or null
attributes - free-form attributes, copied and unmodifiable
All Implemented Interfaces:
MessagePart

public record UnknownPart(String provider, String kind, String rawJson, @Nullable OpaquePayload payload, Map<String,String> attributes) extends Record implements MessagePart
A part that neither an adapter nor this version of Spring AI recognizes, kept verbatim so nothing is silently dropped.

Two things produce an unknown part: a provider adapter that meets a response block it does not model (a citation, a server tool result, a future block type), and deserialization of a part whose type was written by a newer Spring AI version. In the second case provider is SPRING_AI_PROVIDER, so no adapter mistakes it for one of its own blocks. An unknown part is only ever replayed to the provider named in provider.

Since:
2.1.0
Author:
Christian Tzolov
  • Field Details

    • SPRING_AI_PROVIDER

      public static final String SPRING_AI_PROVIDER
      The provider of an unknown part produced by deserializing a type this version does not know.
      See Also:
  • Constructor Details

    • UnknownPart

      public UnknownPart(String provider, String kind, String rawJson, @Nullable OpaquePayload payload, Map<String,String> attributes)
      Creates an instance of a UnknownPart record class.
      Parameters:
      provider - the value for the provider record component
      kind - the value for the kind record component
      rawJson - the value for the rawJson record component
      payload - the value for the payload record component
      attributes - the value for the attributes record component
  • Method Details

    • withAttributes

      public UnknownPart withAttributes(Map<String,String> attributes)
      Description copied from interface: MessagePart
      Returns a copy of this part with the given attributes replacing the current ones. All other components are unchanged.
      Specified by:
      withAttributes in interface MessagePart
      Parameters:
      attributes - the new attributes, copied
      Returns:
      the copy
    • 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.
    • provider

      public String provider()
      Returns the value of the provider record component.
      Returns:
      the value of the provider record component
    • kind

      public String kind()
      Returns the value of the kind record component.
      Returns:
      the value of the kind record component
    • rawJson

      public String rawJson()
      Returns the value of the rawJson record component.
      Returns:
      the value of the rawJson record component
    • payload

      public @Nullable OpaquePayload payload()
      Returns the value of the payload record component.
      Specified by:
      payload in interface MessagePart
      Returns:
      the value of the payload record component
    • attributes

      public Map<String,String> attributes()
      Returns the value of the attributes record component.
      Specified by:
      attributes in interface MessagePart
      Returns:
      the value of the attributes record component