Class AnthropicMediaConverter
java.lang.Object
io.agentscope.extensions.model.anthropic.formatter.AnthropicMediaConverter
Handles media content conversion for Anthropic API.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.anthropic.models.messages.ImageBlockParamconvertDataBlock(io.agentscope.core.message.DataBlock dataBlock) Convert DataBlock to Anthropic ImageBlockParam by resolving MIME type and routing to image.com.anthropic.models.messages.ImageBlockParamconvertImageBlock(io.agentscope.core.message.ImageBlock imageBlock) Convert ImageBlock to Anthropic ImageBlockParam.
-
Constructor Details
-
AnthropicMediaConverter
public AnthropicMediaConverter()
-
-
Method Details
-
convertImageBlock
public com.anthropic.models.messages.ImageBlockParam convertImageBlock(io.agentscope.core.message.ImageBlock imageBlock) throws Exception Convert ImageBlock to Anthropic ImageBlockParam. For local files, converts to base64. For remote URLs, uses URL source directly.- Throws:
Exception
-
convertDataBlock
public com.anthropic.models.messages.ImageBlockParam convertDataBlock(io.agentscope.core.message.DataBlock dataBlock) throws Exception Convert DataBlock to Anthropic ImageBlockParam by resolving MIME type and routing to image.Anthropic currently supports image modality only via this SDK type. Audio and video DataBlocks will throw
IllegalArgumentExceptionsince the Anthropic API does not expose a generic binary content block param yet.MIME type resolution order:
Base64Source.mediaType— always explicitURLSource.mimeType— caller-supplied hint for extension-less URLsMediaUtils.determineMediaType(url)— extension-based inference
- Parameters:
dataBlock- The data block to convert- Returns:
- ImageBlockParam for Anthropic API
- Throws:
Exception- If conversion fails or MIME type resolves to a non-image category
-