mirror of
https://gitee.com/zhijiantianya/ruoyi-vue-pro.git
synced 2026-06-05 18:25:41 +08:00
feat(ai):补充说明下,wan2.7-image 要注意,等 alibaba ai 兼容!!!
This commit is contained in:
@ -109,6 +109,7 @@ public class AiImageServiceImpl implements AiImageService {
|
||||
}
|
||||
|
||||
@Async
|
||||
@SuppressWarnings("ConstantValue")
|
||||
public void executeDrawImage(AiImageDO image, AiImageDrawReqVO reqVO, AiModelDO model) {
|
||||
try {
|
||||
// 1.1 构建请求
|
||||
@ -164,8 +165,8 @@ public class AiImageServiceImpl implements AiImageService {
|
||||
.build();
|
||||
} else if (ObjUtil.equal(model.getPlatform(), AiPlatformEnum.TONG_YI.getPlatform())) {
|
||||
return DashScopeImageOptions.builder()
|
||||
.withModel(model.getModel()).withN(1)
|
||||
.withHeight(draw.getHeight()).withWidth(draw.getWidth())
|
||||
.model(model.getModel()).n(1)
|
||||
.height(draw.getHeight()).width(draw.getWidth())
|
||||
.build();
|
||||
} else if (ObjUtil.equal(model.getPlatform(), AiPlatformEnum.YI_YAN.getPlatform())) {
|
||||
return QianFanImageOptions.builder()
|
||||
|
||||
@ -12,23 +12,34 @@ import org.springframework.ai.image.ImageResponse;
|
||||
/**
|
||||
* {@link DashScopeImageModel} 集成测试类
|
||||
*
|
||||
* TODO @芋艿:注:spring-ai-alibaba-dashscope(1.1.2.2)的 {@code DashScopeImageApi#resolveImagePath} 未给 {@code wan2.7-image} 加路由分支,
|
||||
* 会落到默认的 {@code text2image/image-synthesis} 异步端点 + 旧版 {@code prompt} 入参,
|
||||
* 而该模型实际要求 {@code multimodal-generation/generation} 同步端点 + {@code messages} 入参,
|
||||
* 端点、异步头、入参结构全部对不上,所以走 SDK 直接调用必失败。
|
||||
*
|
||||
* 临时方案:改用 SDK 已支持的 {@code wan2.6-image}(异步)或 {@code qwen-image}(同步);
|
||||
* 或在项目内同包同名覆盖 {@code DashScopeImageApi},把 {@code wan2.7*} 也路由到 {@code wan2.6-image} 那条 {@code image-generation/generation} 异步分支。
|
||||
*
|
||||
* @author fansili
|
||||
*/
|
||||
public class TongYiImagesModelTest {
|
||||
|
||||
private final DashScopeImageModel imageModel = DashScopeImageModel.builder()
|
||||
.dashScopeApi(DashScopeImageApi.builder()
|
||||
.apiKey("sk-47aa124781be4bfb95244cc62f63f7d0")
|
||||
.apiKey("sk-cd9f39e99ea54840bd1888282325f55a") // https://bailian.console.aliyun.com/cn-beijing/?tab=model#/api-key 获取密钥
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// TODO @芋艿:
|
||||
@Test
|
||||
@Disabled
|
||||
public void imageCallTest() {
|
||||
// 准备参数
|
||||
ImageOptions options = DashScopeImageOptions.builder()
|
||||
.withModel("wanx-v1")
|
||||
.withHeight(256).withWidth(256)
|
||||
.model("wan2.7-image")
|
||||
// .withSize("2k")
|
||||
.height(768).width(768)
|
||||
.n(1)
|
||||
.build();
|
||||
ImagePrompt prompt = new ImagePrompt("中国长城!", options);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user