类 Base64Source

java.lang.Object
io.agentscope.core.message.Source
io.agentscope.core.message.Base64Source

public class Base64Source extends Source
Represents Base64-encoded media content with media type and data.

This source is used for embedding media files directly in messages by encoding the binary data as Base64 strings. The format follows the standard MIME type convention with Base64 encoding.

Common media types include:

  • image/jpeg, image/png, image/gif - for images
  • audio/mpeg, audio/wav, audio/ogg - for audio
  • video/mp4, video/avi, video/mov - for video

This approach is useful when media files need to be included directly in messages rather than referenced by URL.

  • 构造器详细资料

    • Base64Source

      public Base64Source(String mediaType, String data)
      Creates a new Base64 source for JSON deserialization.
      参数:
      mediaType - The MIME type of the media content (e.g., "image/jpeg")
      data - The Base64-encoded media data
      抛出:
      NullPointerException - if mediaType or data is null
  • 方法详细资料

    • getMediaType

      public String getMediaType()
      Gets the MIME type of the media content.
      返回:
      The media type as a string (e.g., "image/jpeg")
    • getData

      public String getData()
      Gets the Base64-encoded media data.
      返回:
      The Base64 data string
    • builder

      public static Base64Source.Builder builder()
      Creates a new builder for constructing Base64Source instances.
      返回:
      A new builder instance