AS AgentScopeAPI 手册 / API Reference

DashScopeMediaConverter

public class DashScopeMediaConverter
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMediaConverter.java:36–249

DashScope Media 转换器,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.dashscope.formatter 包。核心成员包括 convertImageBlockToUrl、convertImageBlockToContentPart、convertVideoBlockToUrl、convertVideoBlockToContentPart、convertAudioBlockToUrl、convertAudioBlockToContentPart。

Handles media content conversion for DashScope API. Converts ImageBlock/VideoBlock/AudioBlock to DashScope-compatible formats.

DashScope uses file:// protocol for local files, which differs from OpenAI's base64 approach.

方法摘要Method Summary

方法Method说明Description
public String convertImageBlockToUrl(ImageBlock imageBlock) throws Exception
转换图像块到 URL。
Convert ImageBlock to URL string for DashScope API.
public DashScopeContentPart convertImageBlockToContentPart(ImageBlock imageBlock) throws Exception
转换ImageBlock 到 DashScopeContentPart。
Convert ImageBlock to DashScopeContentPart.
public String convertVideoBlockToUrl(VideoBlock videoBlock) throws Exception
转换视频块到 URL。
Convert VideoBlock to URL string for DashScope API.
public DashScopeContentPart convertVideoBlockToContentPart(VideoBlock videoBlock) throws Exception
转换VideoBlock 到 DashScopeContentPart。
Convert VideoBlock to DashScopeContentPart.
public String convertAudioBlockToUrl(AudioBlock audioBlock) throws Exception
转换音频块到 URL。
Convert AudioBlock to URL string for DashScope API.
public DashScopeContentPart convertAudioBlockToContentPart(AudioBlock audioBlock) throws Exception
转换AudioBlock 到 DashScopeContentPart。
Convert AudioBlock to DashScopeContentPart.
public DashScopeContentPart convertDataBlockToContentPart(DataBlock dataBlock) throws Exception
转换数据块到内容片段。
Convert DataBlock to DashScopeContentPart by resolving the MIME type and routing to the appropriate image / audio / video slot.

方法详情Method Detail

convertImageBlockToUrl

public String convertImageBlockToUrl(ImageBlock imageBlock) throws Exception

转换图像块到 URL。

Convert ImageBlock to URL string for DashScope API.

参数Parameters
名称Name类型Type说明Description
imageBlockImageBlock图像块到转换。The image block to convert
返回Returns String
返回字符串结果。URL string for DashScope API
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMediaConverter.java:56–80

convertImageBlockToContentPart

public DashScopeContentPart convertImageBlockToContentPart(ImageBlock imageBlock) throws Exception

转换ImageBlock 到 DashScopeContentPart。

Convert ImageBlock to DashScopeContentPart.

参数Parameters
名称Name类型Type说明Description
imageBlockImageBlock图像块到转换。The image block to convert
返回Returns DashScopeContentPart
用于图像的DashScopeContentPart。DashScopeContentPart for the image
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMediaConverter.java:89–97

convertVideoBlockToUrl

public String convertVideoBlockToUrl(VideoBlock videoBlock) throws Exception

转换视频块到 URL。

Convert VideoBlock to URL string for DashScope API.

参数Parameters
名称Name类型Type说明Description
videoBlockVideoBlock视频块到转换。The video block to convert
返回Returns String
返回字符串结果。URL string for DashScope API
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMediaConverter.java:116–133

convertVideoBlockToContentPart

public DashScopeContentPart convertVideoBlockToContentPart(VideoBlock videoBlock) throws Exception

转换VideoBlock 到 DashScopeContentPart。

Convert VideoBlock to DashScopeContentPart.

参数Parameters
名称Name类型Type说明Description
videoBlockVideoBlock视频块到转换。The video block to convert
返回Returns DashScopeContentPart
用于视频的DashScopeContentPart。DashScopeContentPart for the video
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMediaConverter.java:142–153

convertAudioBlockToUrl

public String convertAudioBlockToUrl(AudioBlock audioBlock) throws Exception

转换音频块到 URL。

Convert AudioBlock to URL string for DashScope API.

参数Parameters
名称Name类型Type说明Description
audioBlockAudioBlock音频块到转换。The audio block to convert
返回Returns String
返回字符串结果。URL string for DashScope API
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMediaConverter.java:172–189

convertAudioBlockToContentPart

public DashScopeContentPart convertAudioBlockToContentPart(AudioBlock audioBlock) throws Exception

转换AudioBlock 到 DashScopeContentPart。

Convert AudioBlock to DashScopeContentPart.

参数Parameters
名称Name类型Type说明Description
audioBlockAudioBlock音频块到转换。The audio block to convert
返回Returns DashScopeContentPart
用于音频的DashScopeContentPart。DashScopeContentPart for the audio
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMediaConverter.java:198–202

convertDataBlockToContentPart

public DashScopeContentPart convertDataBlockToContentPart(DataBlock dataBlock) throws Exception

转换数据块到内容片段。

Convert DataBlock to DashScopeContentPart by resolving the MIME type and routing to the appropriate image / audio / video slot.

参数Parameters
名称Name类型Type说明Description
dataBlockDataBlock数据块到转换。The data block to convert
返回Returns DashScopeContentPart
返回DashScopeContentPart。DashScopeContentPart for the resolved media type
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMediaConverter.java:219–237
基于官方固定版本源码静态生成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.