Commit d6b3b5e9bd68a355724f0c9af9d6f8076b399dc7
1 parent
28018b1f
【增加】ai image对接通义
Showing
4 changed files
with
6 additions
and
4 deletions
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java
| ... | ... | @@ -137,9 +137,9 @@ public class AiImageServiceImpl implements AiImageService { |
| 137 | 137 | .withStylePreset(String.valueOf(draw.getOptions().get("stylePreset"))) |
| 138 | 138 | .withClipGuidancePreset(String.valueOf(draw.getOptions().get("clipGuidancePreset"))) |
| 139 | 139 | .build(); |
| 140 | - } else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.TONG_YI_WAN_XIANG.getPlatform())) { | |
| 140 | + } else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.TONG_YI.getPlatform())) { | |
| 141 | 141 | return TongYiImagesOptions.builder() |
| 142 | - .withModel(draw.getModel()).withN(Integer.valueOf(draw.getOptions().get("n"))) | |
| 142 | + .withModel(draw.getModel()).withN(1) | |
| 143 | 143 | .withHeight(draw.getHeight()).withWidth(draw.getWidth()) |
| 144 | 144 | .build(); |
| 145 | 145 | } | ... | ... |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/model/AiApiKeyServiceImpl.java
| ... | ... | @@ -106,7 +106,7 @@ public class AiApiKeyServiceImpl implements AiApiKeyService { |
| 106 | 106 | |
| 107 | 107 | @Override |
| 108 | 108 | public ImageModel getImageModel(AiPlatformEnum platform) { |
| 109 | - AiApiKeyDO apiKey = apiKeyMapper.selectFirstByPlatformAndStatus(platform.getName(), CommonStatusEnum.ENABLE.getStatus()); | |
| 109 | + AiApiKeyDO apiKey = apiKeyMapper.selectFirstByPlatformAndStatus(platform.getPlatform(), CommonStatusEnum.ENABLE.getStatus()); | |
| 110 | 110 | if (apiKey == null) { |
| 111 | 111 | throw exception(API_KEY_IMAGE_NODE_FOUND, platform.getName()); |
| 112 | 112 | } | ... | ... |
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/enums/AiPlatformEnum.java
| ... | ... | @@ -28,7 +28,6 @@ public enum AiPlatformEnum { |
| 28 | 28 | STABLE_DIFFUSION("StableDiffusion", "StableDiffusion"), // Stability AI |
| 29 | 29 | MIDJOURNEY("Midjourney", "Midjourney"), // Midjourney |
| 30 | 30 | SUNO("Suno", "Suno"), // Suno AI |
| 31 | - TONG_YI_WAN_XIANG("TongYiWanXiang", "通义万相"), // Suno AI | |
| 32 | 31 | |
| 33 | 32 | ; |
| 34 | 33 | ... | ... |
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/factory/AiModelFactoryImpl.java
| ... | ... | @@ -17,6 +17,7 @@ import com.alibaba.cloud.ai.tongyi.TongYiAutoConfiguration; |
| 17 | 17 | import com.alibaba.cloud.ai.tongyi.TongYiConnectionProperties; |
| 18 | 18 | import com.alibaba.cloud.ai.tongyi.chat.TongYiChatModel; |
| 19 | 19 | import com.alibaba.cloud.ai.tongyi.chat.TongYiChatProperties; |
| 20 | +import com.alibaba.cloud.ai.tongyi.image.TongYiImagesModel; | |
| 20 | 21 | import com.alibaba.dashscope.aigc.generation.Generation; |
| 21 | 22 | import org.springframework.ai.autoconfigure.ollama.OllamaAutoConfiguration; |
| 22 | 23 | import org.springframework.ai.autoconfigure.openai.OpenAiAutoConfiguration; |
| ... | ... | @@ -125,6 +126,8 @@ public class AiModelFactoryImpl implements AiModelFactory { |
| 125 | 126 | return buildOpenAiImageModel(apiKey, url); |
| 126 | 127 | case STABLE_DIFFUSION: |
| 127 | 128 | return buildStabilityAiImageModel(apiKey, url); |
| 129 | + case TONG_YI: | |
| 130 | + return SpringUtil.getBean(TongYiImagesModel.class); | |
| 128 | 131 | default: |
| 129 | 132 | throw new IllegalArgumentException(StrUtil.format("未知平台({})", platform)); |
| 130 | 133 | } | ... | ... |