Commit 4311fe4517fb45d720e15ed3eb45d7bee12edec4

Authored by cherishsince
1 parent 2ae90b9e

【增加】image 对接 Chatglm 模型

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 9 import cn.hutool.extra.spring.SpringUtil;
10 10 import cn.hutool.http.HttpUtil;
11 11 import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum;
  12 +import cn.iocoder.yudao.framework.ai.core.model.chatglm.ChatGlmImageOptions;
12 13 import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi;
13 14 import cn.iocoder.yudao.framework.common.pojo.PageParam;
14 15 import cn.iocoder.yudao.framework.common.pojo.PageResult;
... ... @@ -148,6 +149,10 @@ public class AiImageServiceImpl implements AiImageService {
148 149 .withModel(draw.getModel()).withN(1)
149 150 .withHeight(draw.getHeight()).withWidth(draw.getWidth())
150 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 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 28 STABLE_DIFFUSION("StableDiffusion", "StableDiffusion"), // Stability AI
29 29 MIDJOURNEY("Midjourney", "Midjourney"), // Midjourney
30 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 9 import cn.iocoder.yudao.framework.ai.config.YudaoAiAutoConfiguration;
10 10 import cn.iocoder.yudao.framework.ai.config.YudaoAiProperties;
11 11 import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum;
  12 +import cn.iocoder.yudao.framework.ai.core.model.chatglm.ChatGlmImageModel;
12 13 import cn.iocoder.yudao.framework.ai.core.model.deepseek.DeepSeekChatModel;
13 14 import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi;
14 15 import cn.iocoder.yudao.framework.ai.core.model.suno.api.SunoApi;
... ... @@ -139,6 +140,8 @@ public class AiModelFactoryImpl implements AiModelFactory {
139 140 return buildOpenAiImageModel(apiKey, url);
140 141 case STABLE_DIFFUSION:
141 142 return buildStabilityAiImageModel(apiKey, url);
  143 + case CHATGLM:
  144 + return buildChatGlmModel(apiKey);
142 145 default:
143 146 throw new IllegalArgumentException(StrUtil.format("未知平台({})", platform));
144 147 }
... ... @@ -273,4 +276,7 @@ public class AiModelFactoryImpl implements AiModelFactory {
273 276 return new StabilityAiImageModel(stabilityAiApi);
274 277 }
275 278  
  279 + private ChatGlmImageModel buildChatGlmModel(String apiKey) {
  280 + return new ChatGlmImageModel(apiKey);
  281 + }
276 282 }
... ...