Commit 4311fe4517fb45d720e15ed3eb45d7bee12edec4
1 parent
2ae90b9e
【增加】image 对接 Chatglm 模型
Showing
3 changed files
with
12 additions
and
0 deletions
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java
| @@ -9,6 +9,7 @@ import cn.hutool.core.util.StrUtil; | @@ -9,6 +9,7 @@ import cn.hutool.core.util.StrUtil; | ||
| 9 | import cn.hutool.extra.spring.SpringUtil; | 9 | import cn.hutool.extra.spring.SpringUtil; |
| 10 | import cn.hutool.http.HttpUtil; | 10 | import cn.hutool.http.HttpUtil; |
| 11 | import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum; | 11 | import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum; |
| 12 | +import cn.iocoder.yudao.framework.ai.core.model.chatglm.ChatGlmImageOptions; | ||
| 12 | import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi; | 13 | import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi; |
| 13 | import cn.iocoder.yudao.framework.common.pojo.PageParam; | 14 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 14 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 15 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| @@ -148,6 +149,10 @@ public class AiImageServiceImpl implements AiImageService { | @@ -148,6 +149,10 @@ public class AiImageServiceImpl implements AiImageService { | ||
| 148 | .withModel(draw.getModel()).withN(1) | 149 | .withModel(draw.getModel()).withN(1) |
| 149 | .withHeight(draw.getHeight()).withWidth(draw.getWidth()) | 150 | .withHeight(draw.getHeight()).withWidth(draw.getWidth()) |
| 150 | .build(); | 151 | .build(); |
| 152 | + } else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.CHATGLM.getPlatform())) { | ||
| 153 | + return ChatGlmImageOptions.builder() | ||
| 154 | + .withModel(draw.getModel()) | ||
| 155 | + .build(); | ||
| 151 | } | 156 | } |
| 152 | throw new IllegalArgumentException("不支持的 AI 平台:" + draw.getPlatform()); | 157 | throw new IllegalArgumentException("不支持的 AI 平台:" + draw.getPlatform()); |
| 153 | } | 158 | } |
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/enums/AiPlatformEnum.java
| @@ -28,6 +28,7 @@ public enum AiPlatformEnum { | @@ -28,6 +28,7 @@ public enum AiPlatformEnum { | ||
| 28 | STABLE_DIFFUSION("StableDiffusion", "StableDiffusion"), // Stability AI | 28 | STABLE_DIFFUSION("StableDiffusion", "StableDiffusion"), // Stability AI |
| 29 | MIDJOURNEY("Midjourney", "Midjourney"), // Midjourney | 29 | MIDJOURNEY("Midjourney", "Midjourney"), // Midjourney |
| 30 | SUNO("Suno", "Suno"), // Suno AI | 30 | SUNO("Suno", "Suno"), // Suno AI |
| 31 | + CHATGLM("ChatGlm", "ChatGlm"), // Suno AI | ||
| 31 | 32 | ||
| 32 | ; | 33 | ; |
| 33 | 34 |
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/factory/AiModelFactoryImpl.java
| @@ -9,6 +9,7 @@ import cn.hutool.extra.spring.SpringUtil; | @@ -9,6 +9,7 @@ import cn.hutool.extra.spring.SpringUtil; | ||
| 9 | import cn.iocoder.yudao.framework.ai.config.YudaoAiAutoConfiguration; | 9 | import cn.iocoder.yudao.framework.ai.config.YudaoAiAutoConfiguration; |
| 10 | import cn.iocoder.yudao.framework.ai.config.YudaoAiProperties; | 10 | import cn.iocoder.yudao.framework.ai.config.YudaoAiProperties; |
| 11 | import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum; | 11 | import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum; |
| 12 | +import cn.iocoder.yudao.framework.ai.core.model.chatglm.ChatGlmImageModel; | ||
| 12 | import cn.iocoder.yudao.framework.ai.core.model.deepseek.DeepSeekChatModel; | 13 | import cn.iocoder.yudao.framework.ai.core.model.deepseek.DeepSeekChatModel; |
| 13 | import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi; | 14 | import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi; |
| 14 | import cn.iocoder.yudao.framework.ai.core.model.suno.api.SunoApi; | 15 | import cn.iocoder.yudao.framework.ai.core.model.suno.api.SunoApi; |
| @@ -139,6 +140,8 @@ public class AiModelFactoryImpl implements AiModelFactory { | @@ -139,6 +140,8 @@ public class AiModelFactoryImpl implements AiModelFactory { | ||
| 139 | return buildOpenAiImageModel(apiKey, url); | 140 | return buildOpenAiImageModel(apiKey, url); |
| 140 | case STABLE_DIFFUSION: | 141 | case STABLE_DIFFUSION: |
| 141 | return buildStabilityAiImageModel(apiKey, url); | 142 | return buildStabilityAiImageModel(apiKey, url); |
| 143 | + case CHATGLM: | ||
| 144 | + return buildChatGlmModel(apiKey); | ||
| 142 | default: | 145 | default: |
| 143 | throw new IllegalArgumentException(StrUtil.format("未知平台({})", platform)); | 146 | throw new IllegalArgumentException(StrUtil.format("未知平台({})", platform)); |
| 144 | } | 147 | } |
| @@ -273,4 +276,7 @@ public class AiModelFactoryImpl implements AiModelFactory { | @@ -273,4 +276,7 @@ public class AiModelFactoryImpl implements AiModelFactory { | ||
| 273 | return new StabilityAiImageModel(stabilityAiApi); | 276 | return new StabilityAiImageModel(stabilityAiApi); |
| 274 | } | 277 | } |
| 275 | 278 | ||
| 279 | + private ChatGlmImageModel buildChatGlmModel(String apiKey) { | ||
| 280 | + return new ChatGlmImageModel(apiKey); | ||
| 281 | + } | ||
| 276 | } | 282 | } |