AS AgentScopeAPI 手册 / API Reference

Base64Source

public class Base64Source extends Source
源码Source io/agentscope/core/message/Base64Source.java:39–128

基类 64 来源,在智能体、模型与前端之间传递结构化消息和事件。位于 io.agentscope.core.message 包,继承自 Source。核心成员包括 getMediaType、getData、builder、Base64Source。

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.

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Builder类class
构建器,用于构建并配置目标实例。
Builder for constructing Base64Source instances.

构造器摘要Constructor Summary

构造器Constructor说明Description
public Base64Source(String mediaType, String data)
初始化 `Base64Source` 实例。
Creates a new Base64 source for JSON deserialization.

方法摘要Method Summary

方法Method说明Description
public String getMediaType()
获取 `getMediaType`。
Gets the MIME type of the media content.
public String getData()
获取数据。
Gets the Base64-encoded media data.
public static Builder builder()
static
返回构建器实例。
Creates a new builder for constructing Base64Source instances.

构造器详情Constructor Detail

Base64Source

public Base64Source(String mediaType, String data)

初始化 Base64Source 实例。

Creates a new Base64 source for JSON deserialization.

参数Parameters
名称Name类型Type说明Description
mediaTypeStringmedia 类型(类型 `String`)。The MIME type of the media content (e.g., "image/jpeg")
dataString数据(类型 `String`)。The Base64-encoded media data
抛出Throws
  • NullPointerException 可能抛出 `NullPointerException`。if mediaType or data is null
源码Source io/agentscope/core/message/Base64Source.java:53–58

方法详情Method Detail

getMediaType

public String getMediaType()

获取 getMediaType。

Gets the MIME type of the media content.

返回Returns String
返回字符串结果。The media type as a string (e.g., "image/jpeg")
源码Source io/agentscope/core/message/Base64Source.java:65–67

getData

public String getData()

获取数据。

Gets the Base64-encoded media data.

返回Returns String
返回字符串结果。The Base64 data string
源码Source io/agentscope/core/message/Base64Source.java:74–76

builder

public static Builder builder()
static

返回构建器实例。

Creates a new builder for constructing Base64Source instances.

返回Returns Builder
一种新的构建器实例。A new builder instance
源码Source io/agentscope/core/message/Base64Source.java:83–85

嵌套类详情Nested Class Detail

Builder

public static class Builder

构建器,用于构建并配置目标实例。位于 io.agentscope.core.message 包。核心成员包括 mediaType、data、build。

Builder for constructing Base64Source instances.

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.