| | |
| | | package cn.iocoder.yudao.module.ai.framework.ai.core.model.image; |
| | | |
| | | import cn.hutool.system.SystemUtil; |
| | | import com.alibaba.cloud.ai.dashscope.api.DashScopeImageApi; |
| | | import com.alibaba.cloud.ai.dashscope.image.DashScopeImageModel; |
| | | import com.alibaba.cloud.ai.dashscope.image.DashScopeImageOptions; |
| | |
| | | import org.springframework.ai.image.ImageOptions; |
| | | import org.springframework.ai.image.ImagePrompt; |
| | | import org.springframework.ai.image.ImageResponse; |
| | | |
| | | import static cn.iocoder.yudao.module.ai.util.AiUtils.validateApiKey; |
| | | |
| | | /** |
| | | * {@link DashScopeImageModel} 集成测试类 |
| | |
| | | */ |
| | | public class TongYiImagesModelTest { |
| | | |
| | | private static final String API_KEY = SystemUtil.get("DASHSCOPE_API_KEY", |
| | | "sk-xxxx"); // 按需改成你的 DashScope API Key |
| | | |
| | | private final DashScopeImageModel imageModel = DashScopeImageModel.builder() |
| | | .dashScopeApi(DashScopeImageApi.builder() |
| | | .apiKey("sk-cd9f39e99ea54840bd1888282325f55a") // https://bailian.console.aliyun.com/cn-beijing/?tab=model#/api-key 获取密钥 |
| | | .apiKey(API_KEY) |
| | | .build()) |
| | | .build(); |
| | | |
| | |
| | | @Test |
| | | @Disabled |
| | | public void imageCallTest() { |
| | | validateApiKey(API_KEY); |
| | | // 准备参数 |
| | | ImageOptions options = DashScopeImageOptions.builder() |
| | | .model("wan2.7-image") |