mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	【注释google gami】
This commit is contained in:
		| @@ -22,11 +22,11 @@ | |||||||
|             <artifactId>spring-ai-openai-spring-boot-starter</artifactId> |             <artifactId>spring-ai-openai-spring-boot-starter</artifactId> | ||||||
|             <version>1.0.3</version> |             <version>1.0.3</version> | ||||||
|         </dependency> |         </dependency> | ||||||
|         <dependency> | <!--        <dependency>--> | ||||||
|             <groupId>io.springboot.ai</groupId> | <!--            <groupId>io.springboot.ai</groupId>--> | ||||||
|             <artifactId>spring-ai-vertex-ai-gemini</artifactId> | <!--            <artifactId>spring-ai-vertex-ai-gemini</artifactId>--> | ||||||
|             <version>1.0.3</version> | <!--            <version>1.0.3</version>--> | ||||||
|         </dependency> | <!--        </dependency>--> | ||||||
|  |  | ||||||
|         <dependency> |         <dependency> | ||||||
|             <groupId>cn.iocoder.boot</groupId> |             <groupId>cn.iocoder.boot</groupId> | ||||||
|   | |||||||
| @@ -20,12 +20,8 @@ import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XingHuoApi; | |||||||
| import cn.iocoder.yudao.framework.ai.core.model.yiyan.YiYanChatClient; | import cn.iocoder.yudao.framework.ai.core.model.yiyan.YiYanChatClient; | ||||||
| import cn.iocoder.yudao.framework.ai.core.model.yiyan.YiYanChatOptions; | import cn.iocoder.yudao.framework.ai.core.model.yiyan.YiYanChatOptions; | ||||||
| import cn.iocoder.yudao.framework.ai.core.model.yiyan.api.YiYanApi; | import cn.iocoder.yudao.framework.ai.core.model.yiyan.api.YiYanApi; | ||||||
| import com.google.auth.oauth2.GoogleCredentials; |  | ||||||
| import com.google.cloud.vertexai.VertexAI; |  | ||||||
| import org.springframework.ai.autoconfigure.ollama.OllamaAutoConfiguration; | import org.springframework.ai.autoconfigure.ollama.OllamaAutoConfiguration; | ||||||
| import org.springframework.ai.autoconfigure.openai.OpenAiAutoConfiguration; | import org.springframework.ai.autoconfigure.openai.OpenAiAutoConfiguration; | ||||||
| import org.springframework.ai.autoconfigure.vertexai.gemini.VertexAiGeminiConnectionProperties; |  | ||||||
| import org.springframework.ai.autoconfigure.vertexai.palm2.VertexAiPalm2ConnectionProperties; |  | ||||||
| import org.springframework.ai.chat.StreamingChatClient; | import org.springframework.ai.chat.StreamingChatClient; | ||||||
| import org.springframework.ai.chat.prompt.ChatOptions; | import org.springframework.ai.chat.prompt.ChatOptions; | ||||||
| import org.springframework.ai.ollama.OllamaChatClient; | import org.springframework.ai.ollama.OllamaChatClient; | ||||||
| @@ -35,10 +31,7 @@ import org.springframework.ai.openai.OpenAiChatClient; | |||||||
| import org.springframework.ai.openai.OpenAiChatOptions; | import org.springframework.ai.openai.OpenAiChatOptions; | ||||||
| import org.springframework.ai.openai.api.ApiUtils; | import org.springframework.ai.openai.api.ApiUtils; | ||||||
| import org.springframework.ai.openai.api.OpenAiApi; | import org.springframework.ai.openai.api.OpenAiApi; | ||||||
| import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatClient; |  | ||||||
| import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatOptions; |  | ||||||
|  |  | ||||||
| import java.io.IOException; |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -64,8 +57,8 @@ public class AiClientFactoryImpl implements AiClientFactory { | |||||||
|                     return buildXingHuoChatClient(apiKey); |                     return buildXingHuoChatClient(apiKey); | ||||||
|                 case QIAN_WEN: |                 case QIAN_WEN: | ||||||
|                     return buildQianWenChatClient(apiKey); |                     return buildQianWenChatClient(apiKey); | ||||||
|                 case GEMIR: | //                case GEMIR: | ||||||
|                     return buildGoogleGemir(apiKey); | //                    return buildGoogleGemir(apiKey); | ||||||
|                 default: |                 default: | ||||||
|                     throw new IllegalArgumentException(StrUtil.format("未知平台({})", platform)); |                     throw new IllegalArgumentException(StrUtil.format("未知平台({})", platform)); | ||||||
|             } |             } | ||||||
| @@ -172,24 +165,24 @@ public class AiClientFactoryImpl implements AiClientFactory { | |||||||
|         QianWenApi qianWenApi = new QianWenApi(key, QianWenChatModal.QWEN_72B_CHAT); |         QianWenApi qianWenApi = new QianWenApi(key, QianWenChatModal.QWEN_72B_CHAT); | ||||||
|         return new QianWenChatClient(qianWenApi); |         return new QianWenChatClient(qianWenApi); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static VertexAiGeminiChatClient buildGoogleGemir(String key) { |  | ||||||
|         List<String> keys = StrUtil.split(key, '|'); |  | ||||||
|         Assert.equals(keys.size(), 2, "VertexAiGeminiChatClient 的密钥需要 (projectId|location) 格式"); |  | ||||||
| //        VertexAiGeminiConnectionProperties connectionProperties = new VertexAiGeminiConnectionProperties(); |  | ||||||
| //        connectionProperties.setApiKey("AIzaSyBpe376HTA8uPKJN_OJTh7MEO3v6LMqfXU"); |  | ||||||
| // | // | ||||||
| //        GoogleCredentials credentials = GoogleCredentials.fromStream(connectionProperties.getCredentialsUri().getInputStream()); | //    private static VertexAiGeminiChatClient buildGoogleGemir(String key) { | ||||||
|         // todo @芋艿 google gemini 没找到对于初始化 client 方式,文档中说是用过 GoogleCredentials 来初始化凭证 | //        List<String> keys = StrUtil.split(key, '|'); | ||||||
|         // api-key: AIzaSyBpe376HTA8uPKJN_OJTh7MEO3v6LMqfXU | //        Assert.equals(keys.size(), 2, "VertexAiGeminiChatClient 的密钥需要 (projectId|location) 格式"); | ||||||
|         VertexAI vertexApi =  new VertexAI( | ////        VertexAiGeminiConnectionProperties connectionProperties = new VertexAiGeminiConnectionProperties(); | ||||||
|                 "skilled-snow-409401", | ////        connectionProperties.setApiKey("AIzaSyBpe376HTA8uPKJN_OJTh7MEO3v6LMqfXU"); | ||||||
|                 "us-central1" | //// | ||||||
|         ); | ////        GoogleCredentials credentials = GoogleCredentials.fromStream(connectionProperties.getCredentialsUri().getInputStream()); | ||||||
|         return new VertexAiGeminiChatClient(vertexApi, | //        // todo @芋艿 google gemini 没找到对于初始化 client 方式,文档中说是用过 GoogleCredentials 来初始化凭证 | ||||||
|                 VertexAiGeminiChatOptions.builder() | //        // api-key: AIzaSyBpe376HTA8uPKJN_OJTh7MEO3v6LMqfXU | ||||||
|                         .withTemperature(0.4F) | //        VertexAI vertexApi =  new VertexAI( | ||||||
|                         .withModel(VertexAiGeminiChatClient.ChatModel.GEMINI_PRO.getValue()) | //                "skilled-snow-409401", | ||||||
|                         .build()); | //                "us-central1" | ||||||
|     } | //        ); | ||||||
|  | //        return new VertexAiGeminiChatClient(vertexApi, | ||||||
|  | //                VertexAiGeminiChatOptions.builder() | ||||||
|  | //                        .withTemperature(0.4F) | ||||||
|  | //                        .withModel(VertexAiGeminiChatClient.ChatModel.GEMINI_PRO.getValue()) | ||||||
|  | //                        .build()); | ||||||
|  | //    } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 cherishsince
					cherishsince