|
@@ -20,6 +20,7 @@ import cn.iocoder.yudao.module.ai.dal.mysql.image.AiImageMapper;
|
|
import cn.iocoder.yudao.module.ai.enums.image.AiImageStatusEnum;
|
|
import cn.iocoder.yudao.module.ai.enums.image.AiImageStatusEnum;
|
|
import cn.iocoder.yudao.module.ai.service.model.AiApiKeyService;
|
|
import cn.iocoder.yudao.module.ai.service.model.AiApiKeyService;
|
|
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
|
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
|
|
|
+import com.alibaba.cloud.ai.dashscope.image.DashScopeImageOptions;
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.ai.image.ImageModel;
|
|
import org.springframework.ai.image.ImageModel;
|
|
@@ -133,14 +134,14 @@ public class AiImageServiceImpl implements AiImageService {
|
|
} else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.STABLE_DIFFUSION.getPlatform())) {
|
|
} else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.STABLE_DIFFUSION.getPlatform())) {
|
|
// https://platform.stability.ai/docs/api-reference#tag/SDXL-and-SD1.6/operation/textToImage
|
|
// https://platform.stability.ai/docs/api-reference#tag/SDXL-and-SD1.6/operation/textToImage
|
|
// https://platform.stability.ai/docs/api-reference#tag/Text-to-Image/operation/textToImage
|
|
// https://platform.stability.ai/docs/api-reference#tag/Text-to-Image/operation/textToImage
|
|
- return StabilityAiImageOptions.builder().withModel(draw.getModel())
|
|
|
|
- .withHeight(draw.getHeight()).withWidth(draw.getWidth())
|
|
|
|
- .withSeed(Long.valueOf(draw.getOptions().get("seed")))
|
|
|
|
- .withCfgScale(Float.valueOf(draw.getOptions().get("scale")))
|
|
|
|
- .withSteps(Integer.valueOf(draw.getOptions().get("steps")))
|
|
|
|
- .withSampler(String.valueOf(draw.getOptions().get("sampler")))
|
|
|
|
- .withStylePreset(String.valueOf(draw.getOptions().get("stylePreset")))
|
|
|
|
- .withClipGuidancePreset(String.valueOf(draw.getOptions().get("clipGuidancePreset")))
|
|
|
|
|
|
+ return StabilityAiImageOptions.builder().model(draw.getModel())
|
|
|
|
+ .height(draw.getHeight()).width(draw.getWidth())
|
|
|
|
+ .seed(Long.valueOf(draw.getOptions().get("seed")))
|
|
|
|
+ .cfgScale(Float.valueOf(draw.getOptions().get("scale")))
|
|
|
|
+ .steps(Integer.valueOf(draw.getOptions().get("steps")))
|
|
|
|
+ .sampler(String.valueOf(draw.getOptions().get("sampler")))
|
|
|
|
+ .stylePreset(String.valueOf(draw.getOptions().get("stylePreset")))
|
|
|
|
+ .clipGuidancePreset(String.valueOf(draw.getOptions().get("clipGuidancePreset")))
|
|
.build();
|
|
.build();
|
|
} else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.TONG_YI.getPlatform())) {
|
|
} else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.TONG_YI.getPlatform())) {
|
|
return DashScopeImageOptions.builder()
|
|
return DashScopeImageOptions.builder()
|
|
@@ -149,12 +150,12 @@ public class AiImageServiceImpl implements AiImageService {
|
|
.build();
|
|
.build();
|
|
} else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.YI_YAN.getPlatform())) {
|
|
} else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.YI_YAN.getPlatform())) {
|
|
return QianFanImageOptions.builder()
|
|
return QianFanImageOptions.builder()
|
|
- .withModel(draw.getModel()).withN(1)
|
|
|
|
- .withHeight(draw.getHeight()).withWidth(draw.getWidth())
|
|
|
|
|
|
+ .model(draw.getModel()).N(1)
|
|
|
|
+ .height(draw.getHeight()).width(draw.getWidth())
|
|
.build();
|
|
.build();
|
|
} else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.ZHI_PU.getPlatform())) {
|
|
} else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.ZHI_PU.getPlatform())) {
|
|
return ZhiPuAiImageOptions.builder()
|
|
return ZhiPuAiImageOptions.builder()
|
|
- .withModel(draw.getModel())
|
|
|
|
|
|
+ .model(draw.getModel())
|
|
.build();
|
|
.build();
|
|
}
|
|
}
|
|
throw new IllegalArgumentException("不支持的 AI 平台:" + draw.getPlatform());
|
|
throw new IllegalArgumentException("不支持的 AI 平台:" + draw.getPlatform());
|