Commit 17afb14c88432a2a12fcf7513dd938068d9ab86d

Authored by cherishsince
1 parent 5a711d98

【注释google gami】

yudao-module-ai/yudao-spring-boot-starter-ai/pom.xml
@@ -22,11 +22,11 @@ @@ -22,11 +22,11 @@
22 <artifactId>spring-ai-openai-spring-boot-starter</artifactId> 22 <artifactId>spring-ai-openai-spring-boot-starter</artifactId>
23 <version>1.0.3</version> 23 <version>1.0.3</version>
24 </dependency> 24 </dependency>
25 - <dependency>  
26 - <groupId>io.springboot.ai</groupId>  
27 - <artifactId>spring-ai-vertex-ai-gemini</artifactId>  
28 - <version>1.0.3</version>  
29 - </dependency> 25 +<!-- <dependency>-->
  26 +<!-- <groupId>io.springboot.ai</groupId>-->
  27 +<!-- <artifactId>spring-ai-vertex-ai-gemini</artifactId>-->
  28 +<!-- <version>1.0.3</version>-->
  29 +<!-- </dependency>-->
30 30
31 <dependency> 31 <dependency>
32 <groupId>cn.iocoder.boot</groupId> 32 <groupId>cn.iocoder.boot</groupId>
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/factory/AiClientFactoryImpl.java
@@ -20,12 +20,8 @@ import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XingHuoApi; @@ -20,12 +20,8 @@ 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.auth.oauth2.GoogleCredentials;  
24 -import com.google.cloud.vertexai.VertexAI;  
25 import org.springframework.ai.autoconfigure.ollama.OllamaAutoConfiguration; 23 import org.springframework.ai.autoconfigure.ollama.OllamaAutoConfiguration;
26 import org.springframework.ai.autoconfigure.openai.OpenAiAutoConfiguration; 24 import org.springframework.ai.autoconfigure.openai.OpenAiAutoConfiguration;
27 -import org.springframework.ai.autoconfigure.vertexai.gemini.VertexAiGeminiConnectionProperties;  
28 -import org.springframework.ai.autoconfigure.vertexai.palm2.VertexAiPalm2ConnectionProperties;  
29 import org.springframework.ai.chat.StreamingChatClient; 25 import org.springframework.ai.chat.StreamingChatClient;
30 import org.springframework.ai.chat.prompt.ChatOptions; 26 import org.springframework.ai.chat.prompt.ChatOptions;
31 import org.springframework.ai.ollama.OllamaChatClient; 27 import org.springframework.ai.ollama.OllamaChatClient;
@@ -35,10 +31,7 @@ import org.springframework.ai.openai.OpenAiChatClient; @@ -35,10 +31,7 @@ import org.springframework.ai.openai.OpenAiChatClient;
35 import org.springframework.ai.openai.OpenAiChatOptions; 31 import org.springframework.ai.openai.OpenAiChatOptions;
36 import org.springframework.ai.openai.api.ApiUtils; 32 import org.springframework.ai.openai.api.ApiUtils;
37 import org.springframework.ai.openai.api.OpenAiApi; 33 import org.springframework.ai.openai.api.OpenAiApi;
38 -import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatClient;  
39 -import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatOptions;  
40 34
41 -import java.io.IOException;  
42 import java.util.List; 35 import java.util.List;
43 36
44 /** 37 /**
@@ -64,8 +57,8 @@ public class AiClientFactoryImpl implements AiClientFactory { @@ -64,8 +57,8 @@ public class AiClientFactoryImpl implements AiClientFactory {
64 return buildXingHuoChatClient(apiKey); 57 return buildXingHuoChatClient(apiKey);
65 case QIAN_WEN: 58 case QIAN_WEN:
66 return buildQianWenChatClient(apiKey); 59 return buildQianWenChatClient(apiKey);
67 - case GEMIR:  
68 - return buildGoogleGemir(apiKey); 60 +// case GEMIR:
  61 +// return buildGoogleGemir(apiKey);
69 default: 62 default:
70 throw new IllegalArgumentException(StrUtil.format("未知平台({})", platform)); 63 throw new IllegalArgumentException(StrUtil.format("未知平台({})", platform));
71 } 64 }
@@ -172,24 +165,24 @@ public class AiClientFactoryImpl implements AiClientFactory { @@ -172,24 +165,24 @@ public class AiClientFactoryImpl implements AiClientFactory {
172 QianWenApi qianWenApi = new QianWenApi(key, QianWenChatModal.QWEN_72B_CHAT); 165 QianWenApi qianWenApi = new QianWenApi(key, QianWenChatModal.QWEN_72B_CHAT);
173 return new QianWenChatClient(qianWenApi); 166 return new QianWenChatClient(qianWenApi);
174 } 167 }
175 -  
176 - private static VertexAiGeminiChatClient buildGoogleGemir(String key) {  
177 - List<String> keys = StrUtil.split(key, '|');  
178 - Assert.equals(keys.size(), 2, "VertexAiGeminiChatClient 的密钥需要 (projectId|location) 格式");  
179 -// VertexAiGeminiConnectionProperties connectionProperties = new VertexAiGeminiConnectionProperties();  
180 -// connectionProperties.setApiKey("AIzaSyBpe376HTA8uPKJN_OJTh7MEO3v6LMqfXU");  
181 // 168 //
182 -// GoogleCredentials credentials = GoogleCredentials.fromStream(connectionProperties.getCredentialsUri().getInputStream());  
183 - // todo @芋艿 google gemini 没找到对于初始化 client 方式,文档中说是用过 GoogleCredentials 来初始化凭证  
184 - // api-key: AIzaSyBpe376HTA8uPKJN_OJTh7MEO3v6LMqfXU  
185 - VertexAI vertexApi = new VertexAI(  
186 - "skilled-snow-409401",  
187 - "us-central1"  
188 - );  
189 - return new VertexAiGeminiChatClient(vertexApi,  
190 - VertexAiGeminiChatOptions.builder()  
191 - .withTemperature(0.4F)  
192 - .withModel(VertexAiGeminiChatClient.ChatModel.GEMINI_PRO.getValue())  
193 - .build());  
194 - } 169 +// private static VertexAiGeminiChatClient buildGoogleGemir(String key) {
  170 +// List<String> keys = StrUtil.split(key, '|');
  171 +// Assert.equals(keys.size(), 2, "VertexAiGeminiChatClient 的密钥需要 (projectId|location) 格式");
  172 +//// VertexAiGeminiConnectionProperties connectionProperties = new VertexAiGeminiConnectionProperties();
  173 +//// connectionProperties.setApiKey("AIzaSyBpe376HTA8uPKJN_OJTh7MEO3v6LMqfXU");
  174 +////
  175 +//// GoogleCredentials credentials = GoogleCredentials.fromStream(connectionProperties.getCredentialsUri().getInputStream());
  176 +// // todo @芋艿 google gemini 没找到对于初始化 client 方式,文档中说是用过 GoogleCredentials 来初始化凭证
  177 +// // api-key: AIzaSyBpe376HTA8uPKJN_OJTh7MEO3v6LMqfXU
  178 +// VertexAI vertexApi = new VertexAI(
  179 +// "skilled-snow-409401",
  180 +// "us-central1"
  181 +// );
  182 +// return new VertexAiGeminiChatClient(vertexApi,
  183 +// VertexAiGeminiChatOptions.builder()
  184 +// .withTemperature(0.4F)
  185 +// .withModel(VertexAiGeminiChatClient.ChatModel.GEMINI_PRO.getValue())
  186 +// .build());
  187 +// }
195 } 188 }