This commit is contained in:
2026-02-19 17:50:14 +00:00
parent da95a64fb7
commit 6f629c53a6
171 changed files with 7281 additions and 1144 deletions

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2025 Google. This software is provided as-is, without warranty or representation for any use or purpose.
* Your use of it is subject to your agreement with Google.
*/
package com.example.config;
import com.google.genai.Client;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
/**
* Spring configuration class for initializing the Google Gen AI Client.
* It uses properties from the application's configuration to create a
* singleton `Client` bean for interacting with the Gemini model, ensuring
* proper resource management by specifying a destroy method.
*/
@Configuration
public class GeminiConfig {
private static final Logger logger = LoggerFactory.getLogger(GeminiConfig.class);
@Value("${google.cloud.project}")
private String projectId;
@Value("${google.cloud.location}")
private String location;
@Bean(destroyMethod = "close")
public Client geminiClient() throws IOException {
logger.info("Initializing Google Gen AI Client. Project: {}, Location: {}", projectId, location);
return Client.builder()
.project(projectId)
.location(location)
.vertexAI(true)
.build();
}
}