类 DashScopeMediaConverter
java.lang.Object
io.agentscope.core.formatter.dashscope.DashScopeMediaConverter
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.
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明convertAudioBlockToContentPart(AudioBlock audioBlock) Convert AudioBlock to DashScopeContentPart.convertAudioBlockToUrl(AudioBlock audioBlock) Convert AudioBlock to URL string for DashScope API.convertImageBlockToContentPart(ImageBlock imageBlock) Convert ImageBlock to DashScopeContentPart.convertImageBlockToUrl(ImageBlock imageBlock) Convert ImageBlock to URL string for DashScope API.convertVideoBlockToContentPart(VideoBlock videoBlock) Convert VideoBlock to DashScopeContentPart.convertVideoBlockToUrl(VideoBlock videoBlock) Convert VideoBlock to URL string for DashScope API.
-
构造器详细资料
-
DashScopeMediaConverter
public DashScopeMediaConverter()
-
-
方法详细资料
-
convertImageBlockToUrl
Convert ImageBlock to URL string for DashScope API.Uses file:// protocol for local files for consistent behavior.
Handles:
- Local files → file:// protocol URL (e.g., file:///absolute/path/image.png)
- Remote URLs → Direct URL (e.g., https://example.com/image.png)
- Base64 sources → Data URL (e.g., data:image/png;base64,...)
- 参数:
imageBlock- The image block to convert- 返回:
- URL string for DashScope API
- 抛出:
Exception- If conversion fails
-
convertImageBlockToContentPart
Convert ImageBlock to DashScopeContentPart.- 参数:
imageBlock- The image block to convert- 返回:
- DashScopeContentPart for the image
- 抛出:
Exception- If conversion fails
-
convertVideoBlockToUrl
Convert VideoBlock to URL string for DashScope API.Uses file:// protocol for local files for consistent behavior (same as ImageBlock handling).
Handles:
- Local files → file:// protocol URL (e.g., file:///absolute/path/video.mp4)
- Remote URLs → Direct URL (e.g., https://example.com/video.mp4)
- Base64 sources → Data URL (e.g., data:video/mp4;base64,...)
- 参数:
videoBlock- The video block to convert- 返回:
- URL string for DashScope API
- 抛出:
Exception- If conversion fails
-
convertVideoBlockToContentPart
Convert VideoBlock to DashScopeContentPart.- 参数:
videoBlock- The video block to convert- 返回:
- DashScopeContentPart for the video
- 抛出:
Exception- If conversion fails
-
convertAudioBlockToUrl
Convert AudioBlock to URL string for DashScope API.Uses file:// protocol for local files for consistent behavior (same as ImageBlock handling).
Handles:
- Local files → file:// protocol URL (e.g., file:///absolute/path/audio.mp3)
- Remote URLs → Direct URL (e.g., https://example.com/audio.mp3)
- Base64 sources → Data URL (e.g., data:audio/wav;base64,...)
- 参数:
audioBlock- The audio block to convert- 返回:
- URL string for DashScope API
- 抛出:
Exception- If conversion fails
-
convertAudioBlockToContentPart
Convert AudioBlock to DashScopeContentPart.- 参数:
audioBlock- The audio block to convert- 返回:
- DashScopeContentPart for the audio
- 抛出:
Exception- If conversion fails
-