From cecf9affcb9c07d9c893c7a5180c07e9ccd83425 Mon Sep 17 00:00:00 2001 From: saurabhdhotreknoldus Date: Mon, 24 Jun 2024 15:02:51 +0530 Subject: [PATCH] Changes to read values from property file. --- .../analyzer/config/GeminiConfiguration.java | 15 +++++++++++++-- .../src/main/resources/application.properties | 5 ++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/blogs-analyzer/src/main/java/com/nashtech/blogs/analyzer/config/GeminiConfiguration.java b/blogs-analyzer/src/main/java/com/nashtech/blogs/analyzer/config/GeminiConfiguration.java index d077c1e..8f01103 100644 --- a/blogs-analyzer/src/main/java/com/nashtech/blogs/analyzer/config/GeminiConfiguration.java +++ b/blogs-analyzer/src/main/java/com/nashtech/blogs/analyzer/config/GeminiConfiguration.java @@ -4,6 +4,7 @@ import com.google.cloud.vertexai.generativeai.ChatSession; import com.google.cloud.vertexai.generativeai.GenerativeModel; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.context.annotation.SessionScope; @@ -12,15 +13,25 @@ @Configuration(proxyBeanMethods = false) public class GeminiConfiguration { + + @Value("${spring.ai.vertex.ai.gemini.project-id}") + private String projectId; + + @Value("${spring.ai.vertex.ai.gemini.location}") + private String location; + + @Value("${spring.ai.vertex.ai.gemini.modelName}") + private String modelName; + @Bean public VertexAI vertexAI() throws IOException { - return new VertexAI("gen-lang-client-0999974873", "asia-south1"); + return new VertexAI(projectId, location); } @Bean public GenerativeModel geminiProVisionGenerativeModel(VertexAI vertexAI) { - return new GenerativeModel("gemini-1.0-pro-vision-001", vertexAI); + return new GenerativeModel(modelName, vertexAI); } @Bean diff --git a/blogs-analyzer/src/main/resources/application.properties b/blogs-analyzer/src/main/resources/application.properties index d137ce4..38c5934 100644 --- a/blogs-analyzer/src/main/resources/application.properties +++ b/blogs-analyzer/src/main/resources/application.properties @@ -1,2 +1,5 @@ spring.application.name=blogsAnalyzer -server.port=8888 \ No newline at end of file +server.port=8888 +spring.ai.vertex.ai.gemini.project-id=gen-lang-client-0999974873 +spring.ai.vertex.ai.gemini.location=asia-south1 +spring.ai.vertex.ai.gemini.modelName=gemini-1.0-pro-vision-001 \ No newline at end of file