Record Class MediaPart
java.lang.Object
java.lang.Record
org.springframework.ai.chat.messages.part.MediaPart
- Record Components:
media- the mediapayload- provider data to replay with this part, ornullattributes- free-form attributes, copied and unmodifiable
- All Implemented Interfaces:
MessagePart
public record MediaPart(Media media, @Nullable OpaquePayload payload, Map<String,String> attributes)
extends Record
implements MessagePart
A media element (image, audio, video, document) produced by the model or supplied by
the caller.
Media.getData() is an untyped Object (byte[], String or
URL), so the media is serialized through a small DTO that records which kind of
data it held and restores the same kind on read.
- Since:
- 2.1.0
- Author:
- Christian Tzolov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classJackson converter fromMediaPart.MediaDtotoMedia.static final recordSerialized form of aMedia.static final classJackson converter fromMediatoMediaPart.MediaDto. -
Constructor Summary
Constructors -
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.media()Returns the value of themediarecord component.static MediaPartCreates a media part without payload or attributes.@Nullable OpaquePayloadpayload()Returns the value of thepayloadrecord 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
-
MediaPart
Creates an instance of aMediaPartrecord class.- Parameters:
media- the value for themediarecord 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 media part without payload or attributes.- Parameters:
media- the media- 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). -
media
Returns the value of themediarecord component.- Returns:
- the value of the
mediarecord 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
-