From 870b1bf3695cddd9abfe1f28d2f396fa5e3b0835 Mon Sep 17 00:00:00 2001 From: cherishsince Date: Wed, 10 Jul 2024 10:27:46 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=A2=9E=E5=8A=A0=E3=80=91=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=80=9A=E4=B9=89=E4=B8=87=E8=B1=A1=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/image/TongYiImagesModelTests.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/image/TongYiImagesModelTests.java diff --git a/yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/image/TongYiImagesModelTests.java b/yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/image/TongYiImagesModelTests.java new file mode 100644 index 000000000..c927a0d57 --- /dev/null +++ b/yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/image/TongYiImagesModelTests.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.framework.ai.image; + +import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesis; +import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisParam; +import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisResult; +import com.alibaba.dashscope.exception.NoApiKeyException; +import com.alibaba.dashscope.utils.Constants; +import com.alibaba.fastjson.JSON; +import org.junit.jupiter.api.Test; + +import java.util.Map; + +/** + * 通义万象 - 测试 + */ +public class TongYiImagesModelTests { + + @Test + public void imageCallTest() throws NoApiKeyException { + // 设置 api key + Constants.apiKey="sk-Zsd81gZYg7"; + ImageSynthesisParam param = + ImageSynthesisParam.builder() + .model(ImageSynthesis.Models.WANX_V1) + .n(4) + .size("1024*1024") + .prompt("雄鹰自由自在的在蓝天白云下飞翔") + .build(); + // 创建 ImageSynthesis + ImageSynthesis is = new ImageSynthesis(); + // 调用 call 生成 image + ImageSynthesisResult call = is.call(param); + System.err.println(JSON.toJSON(call)); + for (Map result : call.getOutput().getResults()) { + System.err.println("地址: " + result.get("url")); + } + } +}