Class BaseMediaBlockParser<T extends io.agentscope.core.message.ContentBlock>
java.lang.Object
io.agentscope.core.a2a.agent.message.BaseMediaBlockParser<T>
- Type Parameters:
T- the type of content block to parse
- All Implemented Interfaces:
ContentBlockParser<T>
- Direct Known Subclasses:
AudioBlockParser,ImageBlockParser,VideoBlockParser
public abstract class BaseMediaBlockParser<T extends io.agentscope.core.message.ContentBlock>
extends Object
implements ContentBlockParser<T>
Abstract base parser for media content blocks to
FilePart.
Provides common functionality for parsing Source to FileContent with type:
- Convert
Base64SourcetoFileWithBytes - Convert
URLSourcetoFileWithUri
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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract StringGet the media type for the content block.protected io.a2a.spec.Part<?> parseSource(io.agentscope.core.message.Source source) Parse the source from content block to a FilePart.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.agentscope.core.a2a.agent.message.ContentBlockParser
parse
-
Field Details
-
log
protected final org.slf4j.Logger log
-
-
Constructor Details
-
BaseMediaBlockParser
public BaseMediaBlockParser()
-
-
Method Details
-
getMediaType
Get the media type for the content block.- Returns:
- the media type string
-
parseSource
protected io.a2a.spec.Part<?> parseSource(io.agentscope.core.message.Source source) Parse the source from content block to a FilePart.If input source is unknown type, return null.
- Parameters:
source- the source to parse- Returns:
- the parsed FilePart
-