AS AgentScopeAPI 手册 / API Reference

BaseMediaBlockParser

public abstract class BaseMediaBlockParser<T extends ContentBlock> implements ContentBlockParser<T>
源码Source io/agentscope/core/a2a/agent/message/BaseMediaBlockParser.java:56–114

基类 Media 块解析器,支持智能体之间的发现、委派与协作。位于 io.agentscope.core.a2a.agent.message 包,实现 ContentBlockParser<T>。核心成员包括 getMediaType、parseSource、log。

Abstract base parser for media content blocks to FilePart.

Provides common functionality for parsing Source to FileContent with type:

  • Convert Base64Source to FileWithBytes

  • Convert URLSource to FileWithUri

Due to all FileContent should include FileContent#mimeType(), but Source only Base64Source has Base64Source#getMediaType(), So For URLSource we need to parse URLSource#getUrl() to get FileContent#mimeType().

Source doesn't define name field, so we need to generate a random name set to FileContent#name(). Current use UUID to generate a random name.

字段摘要Field Summary

字段Field类型Type说明Description
log
final
Logger
日志字段。
The log field.

方法摘要Method Summary

方法Method说明Description
protected abstract String getMediaType()
abstract
获取 `getMediaType`。
Get the media type for the content block.
protected Part<?> parseSource(Source source)
解析来源。
Parse the source from content block to a FilePart.

字段详情Field Detail

log

protected final Logger log
final

日志字段。声明为 protected final Logger log。

The log field.

源码Source io/agentscope/core/a2a/agent/message/BaseMediaBlockParser.java:59

方法详情Method Detail

getMediaType

protected abstract String getMediaType()
abstract

获取 getMediaType。

Get the media type for the content block.

返回Returns String
返回字符串结果。the media type string
源码Source io/agentscope/core/a2a/agent/message/BaseMediaBlockParser.java:66

parseSource

protected Part<?> parseSource(Source source)

解析来源。

Parse the source from content block to a FilePart.

参数Parameters
名称Name类型Type说明Description
sourceSource来源到解析。the source to parse
返回Returns Part<?>
已解析 FilePart。the parsed FilePart
源码Source io/agentscope/core/a2a/agent/message/BaseMediaBlockParser.java:76–87
基于官方固定版本源码静态生成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.