DashScopeMultiModalTool
public class DashScopeMultiModalTool
io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:92–1770DashScope Multi Modal 工具,封装可被智能体调用的能力。位于 io.agentscope.extensions.model.dashscope.tool 包。核心成员包括 dashscopeTextToImage、dashscopeImageToImage、dashscopeImageToText、dashscopeTextToAudio、dashscopeAudioToText、dashscopeTextToVideo。
DashScope multimodal tool.
Support tools:
-
dashscope_text_to_image: Generate image(s) based on the given text.
-
dashscope_image_to_image: Edit/transform an image based on a text prompt and the input image.
-
dashscope_image_to_text: Generate text based on the given images.
-
dashscope_text_to_audio: Convert the given text to audio.
-
dashscope_audio_to_text: Convert the given audio to text.
-
dashscope_text_to_video: Generate video based on the given text prompt.
-
dashscope_image_to_video: Generate a video from a single input image and an optional text prompt.
-
dashscope_first_and_last_frame_image_to_video: Generate video transitioning from a first frame to a last frame and an optional text prompt.
-
dashscope_video_to_text: Analyze video and generate a text description or answer questions based on the video content.
convert text to images, convert images to text, convert text to audio, and convert audio to text.
Please refer to the dashscope documentation for more details.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public DashScopeMultiModalTool(String apiKey) | 初始化 `DashScopeMultiModalTool` 实例。 Creates a new instance. |
方法摘要Method Summary
构造器详情Constructor Detail
DashScopeMultiModalTool
public DashScopeMultiModalTool(String apiKey)
初始化 DashScopeMultiModalTool 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
apiKey | String | API 键(类型 `String`)。The api key. |
io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:117–122方法详情Method Detail
dashscopeTextToImage
public Mono<ToolResultBlock> dashscopeTextToImage(String prompt, String model, Integer n, String size, Boolean useBase64)
执行DashScope 文本到图像相关操作。
Generate image(s) based on the given prompt, and return image url(s) or base64 data.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
prompt | String | 提示词(类型 `String`)。The text prompt to generate image |
model | String | 模型实例(类型 `String`)。The model to use, e.g., 'wanx-v1', 'qwen-image', 'wan2.2-t2i-flash', etc. |
n | Integer | n(类型 `Integer`)。The number of images to generate |
size | String | 大小(类型 `String`)。Size of the image, e.g., '1024*1024', '1280*1280', '800*1200', etc. |
useBase64 | Boolean | 使用基类 64(类型 `Boolean`)。Whether to use base64 data for images |
Mono<ToolResultBlock>io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:134–253dashscopeImageToImage
public Mono<ToolResultBlock> dashscopeImageToImage(String imageUrl, String prompt, String model, String size, Boolean useBase64)
执行DashScope 图像到图像相关操作。
Edit or transform an image based on a text prompt and an input image.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
imageUrl | String | 图像 URL(类型 `String`)。The public URL, oss:// URL, local file path, or Base64 data URL of the input image to edit. |
prompt | String | 提示词(类型 `String`)。The text prompt describing the desired edit or transformation. |
model | String | 模型实例(类型 `String`)。The image-edit model to use, e.g., 'qwen-image-edit'. |
size | String | 大小(类型 `String`)。Size of the output image, e.g., '1024*1024'. Supported by the numbered generations (2.0 and later) and by the first-generation 'plus' and 'max' tiers. |
useBase64 | Boolean | 使用基类 64(类型 `Boolean`)。Whether to return image as base64 data instead of URL. |
Mono<ToolResultBlock>io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:272–461dashscopeImageToText
public Mono<ToolResultBlock> dashscopeImageToText(List<String> imageUrls, String prompt, String model)
执行DashScope 图像到文本相关操作。
Generate text based on the given images.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
imageUrls | List<String> | 图像 Urls(类型 `List`)。The URL(s) of image(s) to be converted into text. |
prompt | String | 文本提示词。The text prompt. |
model | String | 模型实例(类型 `String`)。The model to use, e.g., 'qwen3-vl-plus', qwen-vl-plus' 'qvq-plus', etc. |
Mono<ToolResultBlock>io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:588–685dashscopeTextToAudio
public Mono<ToolResultBlock> dashscopeTextToAudio(String text, String model, String voice, String language, Integer sampleRate)
执行DashScope 文本到音频相关操作。
Convert the given text to audio.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
text | String | 文本(类型 `String`)。The text to be converted into audio. |
model | String | 模型实例(类型 `String`)。The TTS model to use. For Qwen TTS: 'qwen3-tts-flash', 'qwen-tts'. For Sambert: 'sambert-zhinan-v1', 'sambert-zhiqi-v1', 'sambert-zhichu-v1', etc. |
voice | String | 语音(类型 `String`)。Voice name for Qwen TTS models, e.g., 'Cherry', 'Serena'. Ignored for Sambert models. |
language | String | language(类型 `String`)。Language type for Qwen TTS, e.g., 'Chinese', 'English'. Ignored for Sambert models. |
sampleRate | Integer | sample 速率(类型 `Integer`)。Sample rate of the audio (e.g., 16000, 24000, 48000). |
Mono<ToolResultBlock>io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:704–760dashscopeAudioToText
public Mono<ToolResultBlock> dashscopeAudioToText(String audioUrl, String model, Integer sampleRate)
执行DashScope 音频到文本相关操作。
Convert the given audio to text.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
audioUrl | String | 音频 URL(类型 `String`)。The file path or URL of audio to be converted into text. |
model | String | 模型实例(类型 `String`)。The speech recognition model to use, e.g., 'paraformer-realtime-v1', 'paraformer-realtime-8k-v1', 'paraformer-realtime-v2', 'paraformer-realtime-8k-v2'. |
sampleRate | Integer | sample 速率(类型 `Integer`)。Sample rate of the audio (e.g., 8000, 16000). |
Mono<ToolResultBlock>io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:970–1076dashscopeTextToVideo
public Mono<ToolResultBlock> dashscopeTextToVideo(String prompt, String model, String negativePrompt, String audioUrl, String size, Integer duration, String shotType, Boolean promptExtend, Boolean watermark, Integer seed)
执行DashScope 文本到视频相关操作。
Generate video based on the given prompt.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
prompt | String | 提示词(类型 `String`)。The text prompt to generate video. |
model | String | 模型实例(类型 `String`)。The model to use, e.g., 'wan2.6-t2v', 'wan2.5-t2v-preview', etc. |
negativePrompt | String | negative 提示词(类型 `String`)。The negative prompt to avoid certain elements. |
audioUrl | String | 音频 URL(类型 `String`)。The URL for background audio. |
size | String | 大小(类型 `String`)。Size of the video, e.g., '1920*1080', '1280*720', etc. |
duration | Integer | 时长(类型 `Integer`)。Duration of the video in seconds, e.g., '5', '10', etc. |
shotType | String | shot 类型(类型 `String`)。Specify the shot type that generates the video. single: default value, output single shot video; multi: output multi-lens video. |
promptExtend | Boolean | 提示词 Extend(类型 `Boolean`)。Whether to extend the prompt automatically (default true) |
watermark | Boolean | watermark(类型 `Boolean`)。Whether to include watermark (default false) |
seed | Integer | 预置(类型 `Integer`)。The seed for reproducibility |
Mono<ToolResultBlock>io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:1133–1273dashscopeImageToVideo
public Mono<ToolResultBlock> dashscopeImageToVideo(String prompt, String model, String imageUrl, String audioUrl, String negativePrompt, String template, String resolution, Integer duration, String shotType, Boolean audio, Boolean promptExtend, Boolean watermark, Integer seed)
执行DashScope 图像到视频相关操作。
Generate a video based on a single input image (first frame) and an optional text prompt.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
prompt | String | 提示词(类型 `String`)。The text prompt describing the video content and motion. |
model | String | 模型实例(类型 `String`)。The model to use, e.g., 'wan2.6-i2v-flash', 'wan2.1-i2v-turbo'. |
imageUrl | String | 图像 URL(类型 `String`)。The URL, local file path, or Base64 data of the input image (first frame). |
audioUrl | String | 音频 URL(类型 `String`)。URL of the audio file that the model will use to generate video. |
negativePrompt | String | negative 提示词(类型 `String`)。The negative prompt to avoid certain elements. |
template | String | 模板(类型 `String`)。Name of video effect template, e.g., 'squish', 'rotation', etc |
resolution | String | resolution(类型 `String`)。Resolution of the video, e.g., '720P', '1080P'. |
duration | Integer | 时长(类型 `Integer`)。Duration of the video in seconds (e.g., 5, 10, 15). Default depends on model. |
shotType | String | shot 类型(类型 `String`)。Specify the shot type that generates the video. single: default value, output single shot video; multi: output multi-lens video. |
audio | Boolean | 音频(类型 `Boolean`)。Whether to generate audio video (default true). |
promptExtend | Boolean | 提示词 Extend(类型 `Boolean`)。Whether to automatically extend the prompt (default true). |
watermark | Boolean | watermark(类型 `Boolean`)。Whether to include watermark (default false). |
seed | Integer | 预置(类型 `Integer`)。Optional seed for reproducibility. |
Mono<ToolResultBlock>io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:1294–1470dashscopeFirstAndLastFrameImageToVideo
public Mono<ToolResultBlock> dashscopeFirstAndLastFrameImageToVideo(String prompt, String model, String firstFrameUrl, String lastFrameUrl, String negativePrompt, String template, String resolution, Boolean promptExtend, Boolean watermark, Integer seed)
执行 dashscopeFirstAndLastFrameImageToVideo 方法。
Generate video transitioning from a first frame to a last frame and an optional text prompt.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
prompt | String | 提示词(类型 `String`)。The text prompt describing the video content and camera movement. |
model | String | 模型实例(类型 `String`)。The model to use, e.g., 'wan2.2-kf2v-flash', 'wanx2.1-kf2v-plus'. |
firstFrameUrl | String | 第一个 Frame URL(类型 `String`)。The URL or Base64 data of the first frame image. |
lastFrameUrl | String | 最后 Frame URL(类型 `String`)。The URL or Base64 data of the last frame image. |
negativePrompt | String | negative 提示词(类型 `String`)。The negative prompt to avoid certain elements. |
template | String | 模板(类型 `String`)。Name of video effect template, e.g., 'hanfu-1', 'solaron', etc. |
resolution | String | resolution(类型 `String`)。Resolution of the video, e.g., '480P', '720P', '1080P'. |
promptExtend | Boolean | 提示词 Extend(类型 `Boolean`)。Whether to automatically extend the prompt (default true). |
watermark | Boolean | watermark(类型 `Boolean`)。Whether to include watermark (default false). |
seed | Integer | 预置(类型 `Integer`)。Optional seed for reproducibility. |
Mono<ToolResultBlock>io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:1487–1640dashscopeVideoToText
public Mono<ToolResultBlock> dashscopeVideoToText(String videoUrl, String prompt, String model, Double fps)
执行DashScope 视频到文本相关操作。
Analyze video and generate a text description or answer questions based on the video content.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
videoUrl | String | 视频 URL(类型 `String`)。The URL or local path of the video to analyze. |
prompt | String | 提示词(类型 `String`)。The text prompt or question regarding the video content. |
model | String | 模型实例(类型 `String`)。The vision model to use, e.g., 'qwen3.5-plus', 'qwen3.5-flash', 'qwen3-vl-plus', 'qwen3-vl-flash', etc. |
fps | Double | fps(类型 `Double`)。Frames per second to sample from the video (e.g., 1, 2, 4). Default is 2. |
Mono<ToolResultBlock>io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:1651–1769