Commit db7315b8cd79807ef24822e8aa042d6dd88aef17
1 parent
88d7c90c
【增加】百度千帆
Showing
2 changed files
with
8 additions
and
1 deletions
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/model/AiApiKeyServiceImpl.java
| @@ -132,5 +132,4 @@ public class AiApiKeyServiceImpl implements AiApiKeyService { | @@ -132,5 +132,4 @@ public class AiApiKeyServiceImpl implements AiApiKeyService { | ||
| 132 | } | 132 | } |
| 133 | return modelFactory.getOrCreateSunoApi(apiKey.getApiKey(), apiKey.getUrl()); | 133 | return modelFactory.getOrCreateSunoApi(apiKey.getApiKey(), apiKey.getUrl()); |
| 134 | } | 134 | } |
| 135 | - | ||
| 136 | } | 135 | } |
| 137 | \ No newline at end of file | 136 | \ No newline at end of file |
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/factory/AiModelFactoryImpl.java
| @@ -38,7 +38,9 @@ import org.springframework.ai.openai.api.ApiUtils; | @@ -38,7 +38,9 @@ import org.springframework.ai.openai.api.ApiUtils; | ||
| 38 | import org.springframework.ai.openai.api.OpenAiApi; | 38 | import org.springframework.ai.openai.api.OpenAiApi; |
| 39 | import org.springframework.ai.openai.api.OpenAiImageApi; | 39 | import org.springframework.ai.openai.api.OpenAiImageApi; |
| 40 | import org.springframework.ai.qianfan.QianFanChatModel; | 40 | import org.springframework.ai.qianfan.QianFanChatModel; |
| 41 | +import org.springframework.ai.qianfan.QianFanImageModel; | ||
| 41 | import org.springframework.ai.qianfan.api.QianFanApi; | 42 | import org.springframework.ai.qianfan.api.QianFanApi; |
| 43 | +import org.springframework.ai.qianfan.api.QianFanImageApi; | ||
| 42 | import org.springframework.ai.stabilityai.StabilityAiImageModel; | 44 | import org.springframework.ai.stabilityai.StabilityAiImageModel; |
| 43 | import org.springframework.ai.stabilityai.api.StabilityAiApi; | 45 | import org.springframework.ai.stabilityai.api.StabilityAiApi; |
| 44 | import org.springframework.ai.zhipuai.ZhiPuAiChatModel; | 46 | import org.springframework.ai.zhipuai.ZhiPuAiChatModel; |
| @@ -128,6 +130,8 @@ public class AiModelFactoryImpl implements AiModelFactory { | @@ -128,6 +130,8 @@ public class AiModelFactoryImpl implements AiModelFactory { | ||
| 128 | return buildStabilityAiImageModel(apiKey, url); | 130 | return buildStabilityAiImageModel(apiKey, url); |
| 129 | case TONG_YI: | 131 | case TONG_YI: |
| 130 | return SpringUtil.getBean(TongYiImagesModel.class); | 132 | return SpringUtil.getBean(TongYiImagesModel.class); |
| 133 | + case YI_YAN: | ||
| 134 | + return buildQianFanImageModel(apiKey); | ||
| 131 | default: | 135 | default: |
| 132 | throw new IllegalArgumentException(StrUtil.format("未知平台({})", platform)); | 136 | throw new IllegalArgumentException(StrUtil.format("未知平台({})", platform)); |
| 133 | } | 137 | } |
| @@ -242,4 +246,8 @@ public class AiModelFactoryImpl implements AiModelFactory { | @@ -242,4 +246,8 @@ public class AiModelFactoryImpl implements AiModelFactory { | ||
| 242 | return new StabilityAiImageModel(stabilityAiApi); | 246 | return new StabilityAiImageModel(stabilityAiApi); |
| 243 | } | 247 | } |
| 244 | 248 | ||
| 249 | + private QianFanImageModel buildQianFanImageModel(String key) { | ||
| 250 | + List<String> keys = StrUtil.split(key, '|'); | ||
| 251 | + return new QianFanImageModel(new QianFanImageApi(keys.get(0), keys.get(1))); | ||
| 252 | + } | ||
| 245 | } | 253 | } |