Commit 5618313d65b342ff2ae413a970e3ad0f93501aa6

Authored by cherishsince
1 parent 8f0c5998

【优化】处理 build xing huo key size 判断问题

yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/factory/AiClientFactoryImpl.java
@@ -20,6 +20,7 @@ import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XingHuoApi; @@ -20,6 +20,7 @@ import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XingHuoApi;
20 import cn.iocoder.yudao.framework.ai.core.model.yiyan.YiYanChatClient; 20 import cn.iocoder.yudao.framework.ai.core.model.yiyan.YiYanChatClient;
21 import cn.iocoder.yudao.framework.ai.core.model.yiyan.YiYanChatOptions; 21 import cn.iocoder.yudao.framework.ai.core.model.yiyan.YiYanChatOptions;
22 import cn.iocoder.yudao.framework.ai.core.model.yiyan.api.YiYanApi; 22 import cn.iocoder.yudao.framework.ai.core.model.yiyan.api.YiYanApi;
  23 +import com.google.cloud.vertexai.VertexAI;
23 import org.springframework.ai.autoconfigure.ollama.OllamaAutoConfiguration; 24 import org.springframework.ai.autoconfigure.ollama.OllamaAutoConfiguration;
24 import org.springframework.ai.autoconfigure.openai.OpenAiAutoConfiguration; 25 import org.springframework.ai.autoconfigure.openai.OpenAiAutoConfiguration;
25 import org.springframework.ai.chat.StreamingChatClient; 26 import org.springframework.ai.chat.StreamingChatClient;
@@ -31,6 +32,8 @@ import org.springframework.ai.openai.OpenAiChatClient; @@ -31,6 +32,8 @@ import org.springframework.ai.openai.OpenAiChatClient;
31 import org.springframework.ai.openai.OpenAiChatOptions; 32 import org.springframework.ai.openai.OpenAiChatOptions;
32 import org.springframework.ai.openai.api.ApiUtils; 33 import org.springframework.ai.openai.api.ApiUtils;
33 import org.springframework.ai.openai.api.OpenAiApi; 34 import org.springframework.ai.openai.api.OpenAiApi;
  35 +import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatClient;
  36 +import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatOptions;
34 37
35 import java.util.List; 38 import java.util.List;
36 39
@@ -57,6 +60,8 @@ public class AiClientFactoryImpl implements AiClientFactory { @@ -57,6 +60,8 @@ public class AiClientFactoryImpl implements AiClientFactory {
57 return buildXingHuoChatClient(apiKey); 60 return buildXingHuoChatClient(apiKey);
58 case QIAN_WEN: 61 case QIAN_WEN:
59 return buildQianWenChatClient(apiKey); 62 return buildQianWenChatClient(apiKey);
  63 + case GEMIR:
  64 + return buildGoogleGemir(apiKey);
60 default: 65 default:
61 throw new IllegalArgumentException(StrUtil.format("未知平台({})", platform)); 66 throw new IllegalArgumentException(StrUtil.format("未知平台({})", platform));
62 } 67 }
@@ -148,7 +153,7 @@ public class AiClientFactoryImpl implements AiClientFactory { @@ -148,7 +153,7 @@ public class AiClientFactoryImpl implements AiClientFactory {
148 */ 153 */
149 private static XingHuoChatClient buildXingHuoChatClient(String key) { 154 private static XingHuoChatClient buildXingHuoChatClient(String key) {
150 List<String> keys = StrUtil.split(key, '|'); 155 List<String> keys = StrUtil.split(key, '|');
151 - Assert.equals(keys.size(), 2, "XingHuoChatClient 的密钥需要 (appKey|secretKey) 格式"); 156 + Assert.equals(keys.size(), 3, "XingHuoChatClient 的密钥需要 (appid|appKey|secretKey) 格式");
152 String appId = keys.get(0); 157 String appId = keys.get(0);
153 String appKey = keys.get(1); 158 String appKey = keys.get(1);
154 String secretKey = keys.get(2); 159 String secretKey = keys.get(2);