Commit 17afb14c88432a2a12fcf7513dd938068d9ab86d
1 parent
5a711d98
【注释google gami】
Showing
2 changed files
with
26 additions
and
33 deletions
yudao-module-ai/yudao-spring-boot-starter-ai/pom.xml
| ... | ... | @@ -22,11 +22,11 @@ |
| 22 | 22 | <artifactId>spring-ai-openai-spring-boot-starter</artifactId> |
| 23 | 23 | <version>1.0.3</version> |
| 24 | 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 | 31 | <dependency> |
| 32 | 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 | 20 | import cn.iocoder.yudao.framework.ai.core.model.yiyan.YiYanChatClient; |
| 21 | 21 | import cn.iocoder.yudao.framework.ai.core.model.yiyan.YiYanChatOptions; |
| 22 | 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 | 23 | import org.springframework.ai.autoconfigure.ollama.OllamaAutoConfiguration; |
| 26 | 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 | 25 | import org.springframework.ai.chat.StreamingChatClient; |
| 30 | 26 | import org.springframework.ai.chat.prompt.ChatOptions; |
| 31 | 27 | import org.springframework.ai.ollama.OllamaChatClient; |
| ... | ... | @@ -35,10 +31,7 @@ import org.springframework.ai.openai.OpenAiChatClient; |
| 35 | 31 | import org.springframework.ai.openai.OpenAiChatOptions; |
| 36 | 32 | import org.springframework.ai.openai.api.ApiUtils; |
| 37 | 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 | 35 | import java.util.List; |
| 43 | 36 | |
| 44 | 37 | /** |
| ... | ... | @@ -64,8 +57,8 @@ public class AiClientFactoryImpl implements AiClientFactory { |
| 64 | 57 | return buildXingHuoChatClient(apiKey); |
| 65 | 58 | case QIAN_WEN: |
| 66 | 59 | return buildQianWenChatClient(apiKey); |
| 67 | - case GEMIR: | |
| 68 | - return buildGoogleGemir(apiKey); | |
| 60 | +// case GEMIR: | |
| 61 | +// return buildGoogleGemir(apiKey); | |
| 69 | 62 | default: |
| 70 | 63 | throw new IllegalArgumentException(StrUtil.format("未知平台({})", platform)); |
| 71 | 64 | } |
| ... | ... | @@ -172,24 +165,24 @@ public class AiClientFactoryImpl implements AiClientFactory { |
| 172 | 165 | QianWenApi qianWenApi = new QianWenApi(key, QianWenChatModal.QWEN_72B_CHAT); |
| 173 | 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 | } | ... | ... |