From b13af42ac55b43c992f0ae799de354be4dea3bac Mon Sep 17 00:00:00 2001 From: rajadilipkolli Date: Sun, 7 Jul 2024 02:50:13 +0530 Subject: [PATCH] polish : upgrade to spring-ai 1.0.0-M1 --- chatbot/chatbot-openai-springai/pom.xml | 22 ++++++------- .../src/main/resources/application.properties | 2 ++ embeddingstores/neo4j-springai/pom.xml | 8 ++--- .../ai/Neo4jVectorEmbeddingStoreExample.java | 2 +- .../com/learning/ai/config/Initializer.java | 2 +- .../config/ResponseHeadersModification.java | 2 +- .../com/learning/ai/config/SwaggerConfig.java | 2 +- .../ai/controller/QueryController.java | 2 +- embeddingstores/pgvector-springai/pom.xml | 33 ++++++++++++++++--- .../com/learning/ai/config/Initializer.java | 2 +- .../config/ResponseHeadersModification.java | 2 +- .../com/learning/ai/config/SwaggerConfig.java | 2 +- .../ai/controller/QueryController.java | 2 +- .../LlmRagWithSpringAiApplicationIntTest.java | 5 +-- .../LlmRagWithSpringAiApplication.java | 2 +- .../llmragwithspringai/config/AppConfig.java | 2 +- .../config/FunctionConfiguration.java | 2 +- .../config/GlobalExceptionHandler.java | 2 +- .../config/ResponseHeadersModification.java | 2 +- .../config/SwaggerConfig.java | 2 +- .../controller/AiController.java | 2 +- 21 files changed, 65 insertions(+), 37 deletions(-) diff --git a/chatbot/chatbot-openai-springai/pom.xml b/chatbot/chatbot-openai-springai/pom.xml index 98717fd..430de12 100644 --- a/chatbot/chatbot-openai-springai/pom.xml +++ b/chatbot/chatbot-openai-springai/pom.xml @@ -18,7 +18,7 @@ 17 2.43.0 - 1.0.0-SNAPSHOT + 1.0.0-M1 @@ -122,22 +122,22 @@ - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + false - + - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + false - + diff --git a/chatbot/chatbot-openai-springai/src/main/resources/application.properties b/chatbot/chatbot-openai-springai/src/main/resources/application.properties index bab13b3..366ef9d 100644 --- a/chatbot/chatbot-openai-springai/src/main/resources/application.properties +++ b/chatbot/chatbot-openai-springai/src/main/resources/application.properties @@ -8,6 +8,8 @@ spring.ai.openai.base-url=http://langchain4j.dev/demo/openai spring.ai.openai.chat.options.model=gpt-3.5-turbo spring.ai.openai.chat.options.temperature=0.7 +spring.ai.vectorstore.milvus.collectionName=SpringAiCollection + spring.ai.openai.embedding.enabled=true spring.testcontainers.beans.startup=parallel diff --git a/embeddingstores/neo4j-springai/pom.xml b/embeddingstores/neo4j-springai/pom.xml index 9bec4a4..2cca29b 100644 --- a/embeddingstores/neo4j-springai/pom.xml +++ b/embeddingstores/neo4j-springai/pom.xml @@ -18,7 +18,7 @@ UTF-8 21 - 0.8.1 + 1.0.0-M1 2.43.0 @@ -57,8 +57,8 @@ test - org.springframework.boot - spring-boot-testcontainers + org.springframework.ai + spring-ai-spring-boot-testcontainers test @@ -98,7 +98,7 @@ - 2.40.0 + 2.47.0 diff --git a/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/Neo4jVectorEmbeddingStoreExample.java b/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/Neo4jVectorEmbeddingStoreExample.java index 8a90ccc..ced04fe 100644 --- a/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/Neo4jVectorEmbeddingStoreExample.java +++ b/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/Neo4jVectorEmbeddingStoreExample.java @@ -4,7 +4,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class Neo4jVectorEmbeddingStoreExample { +class Neo4jVectorEmbeddingStoreExample { public static void main(String[] args) { SpringApplication.run(Neo4jVectorEmbeddingStoreExample.class, args); diff --git a/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/config/Initializer.java b/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/config/Initializer.java index 893a82b..5d69ca5 100644 --- a/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/config/Initializer.java +++ b/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/config/Initializer.java @@ -5,7 +5,7 @@ import org.springframework.stereotype.Component; @Component -public class Initializer implements CommandLineRunner { +class Initializer implements CommandLineRunner { private final Neo4jVectorStoreService neo4jVectorStoreService; diff --git a/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/config/ResponseHeadersModification.java b/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/config/ResponseHeadersModification.java index ce86d3c..879acaf 100644 --- a/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/config/ResponseHeadersModification.java +++ b/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/config/ResponseHeadersModification.java @@ -16,7 +16,7 @@ @Configuration(proxyBeanMethods = false) @ConditionalOnProperty(value = "spring.ai.openai.api-key", havingValue = "demo") -public class ResponseHeadersModification { +class ResponseHeadersModification { @Bean RestClient.Builder restClientBuilder() { diff --git a/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/config/SwaggerConfig.java b/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/config/SwaggerConfig.java index c543547..b84b15e 100644 --- a/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/config/SwaggerConfig.java +++ b/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/config/SwaggerConfig.java @@ -7,4 +7,4 @@ @Configuration(proxyBeanMethods = false) @OpenAPIDefinition(info = @Info(title = "pgvector-springai", version = "v1.0.0"), servers = @Server(url = "/")) -public class SwaggerConfig {} +class SwaggerConfig {} diff --git a/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/controller/QueryController.java b/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/controller/QueryController.java index 371ab29..dc1ee5c 100644 --- a/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/controller/QueryController.java +++ b/embeddingstores/neo4j-springai/src/main/java/com/learning/ai/controller/QueryController.java @@ -10,7 +10,7 @@ @RestController @RequestMapping("/api/ai") -public class QueryController { +class QueryController { private final Neo4jVectorStoreService neo4jVectorStoreService; diff --git a/embeddingstores/pgvector-springai/pom.xml b/embeddingstores/pgvector-springai/pom.xml index 3658758..b43682d 100644 --- a/embeddingstores/pgvector-springai/pom.xml +++ b/embeddingstores/pgvector-springai/pom.xml @@ -17,8 +17,10 @@ UTF-8 - 17 - 0.8.1 + 21 + 1.0.0-M1 + + 2.43.0 @@ -56,8 +58,8 @@ test - org.springframework.boot - spring-boot-testcontainers + org.springframework.ai + spring-ai-spring-boot-testcontainers test @@ -90,6 +92,29 @@ org.springframework.boot spring-boot-maven-plugin + + com.diffplug.spotless + spotless-maven-plugin + ${spotless.version} + + + + 2.47.0 + + + + + + + + + compile + + check + + + + diff --git a/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/config/Initializer.java b/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/config/Initializer.java index eb3507c..b6cd99c 100644 --- a/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/config/Initializer.java +++ b/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/config/Initializer.java @@ -5,7 +5,7 @@ import org.springframework.stereotype.Component; @Component -public class Initializer implements CommandLineRunner { +class Initializer implements CommandLineRunner { private final PgVectorStoreService pgVectorStoreService; diff --git a/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/config/ResponseHeadersModification.java b/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/config/ResponseHeadersModification.java index ce86d3c..879acaf 100644 --- a/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/config/ResponseHeadersModification.java +++ b/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/config/ResponseHeadersModification.java @@ -16,7 +16,7 @@ @Configuration(proxyBeanMethods = false) @ConditionalOnProperty(value = "spring.ai.openai.api-key", havingValue = "demo") -public class ResponseHeadersModification { +class ResponseHeadersModification { @Bean RestClient.Builder restClientBuilder() { diff --git a/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/config/SwaggerConfig.java b/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/config/SwaggerConfig.java index c543547..b84b15e 100644 --- a/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/config/SwaggerConfig.java +++ b/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/config/SwaggerConfig.java @@ -7,4 +7,4 @@ @Configuration(proxyBeanMethods = false) @OpenAPIDefinition(info = @Info(title = "pgvector-springai", version = "v1.0.0"), servers = @Server(url = "/")) -public class SwaggerConfig {} +class SwaggerConfig {} diff --git a/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/controller/QueryController.java b/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/controller/QueryController.java index c36d6a5..20935d5 100644 --- a/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/controller/QueryController.java +++ b/embeddingstores/pgvector-springai/src/main/java/com/learning/ai/controller/QueryController.java @@ -9,7 +9,7 @@ @RestController @RequestMapping("/api/ai") -public class QueryController { +class QueryController { private final PgVectorStoreService pgVectorStoreService; diff --git a/rag/rag-springai-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java b/rag/rag-springai-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java index d3b4090..7e4db2b 100644 --- a/rag/rag-springai-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java +++ b/rag/rag-springai-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java @@ -2,6 +2,7 @@ import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.containsStringIgnoringCase; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; @@ -70,7 +71,7 @@ void testRag() { .post("/api/ai/chat") .then() .statusCode(200) - .body("queryResponse", containsString("yes")) + .body("queryResponse", containsStringIgnoringCase("yes")) .log() .all(); } @@ -84,7 +85,7 @@ void testRag2() { .post("/api/ai/chat") .then() .statusCode(200) - .body("queryResponse", containsString("No")) + .body("queryResponse", containsStringIgnoringCase("No")) .log() .all(); } diff --git a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplication.java b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplication.java index 076804c..cb1894d 100644 --- a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplication.java +++ b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplication.java @@ -4,7 +4,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class LlmRagWithSpringAiApplication { +class LlmRagWithSpringAiApplication { public static void main(String[] args) { SpringApplication.run(LlmRagWithSpringAiApplication.class, args); diff --git a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/AppConfig.java b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/AppConfig.java index 1d8a11e..9823127 100644 --- a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/AppConfig.java +++ b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/AppConfig.java @@ -14,7 +14,7 @@ import org.springframework.jdbc.core.JdbcTemplate; @Configuration(proxyBeanMethods = false) -public class AppConfig { +class AppConfig { private static final Logger log = LoggerFactory.getLogger(AppConfig.class); @Value("classpath:Rohit_Gurunath_Sharma.docx") diff --git a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/FunctionConfiguration.java b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/FunctionConfiguration.java index 9aa1a4e..9059a53 100644 --- a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/FunctionConfiguration.java +++ b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/FunctionConfiguration.java @@ -9,7 +9,7 @@ import org.springframework.context.annotation.Description; @Configuration(proxyBeanMethods = false) -public class FunctionConfiguration { +class FunctionConfiguration { private static final Logger log = LoggerFactory.getLogger(FunctionConfiguration.class); diff --git a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/GlobalExceptionHandler.java b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/GlobalExceptionHandler.java index c2a2c76..30e1b1f 100644 --- a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/GlobalExceptionHandler.java +++ b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/GlobalExceptionHandler.java @@ -17,7 +17,7 @@ @Order(Ordered.HIGHEST_PRECEDENCE) @ControllerAdvice -public class GlobalExceptionHandler { +class GlobalExceptionHandler { @ExceptionHandler(MethodArgumentNotValidException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) diff --git a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/ResponseHeadersModification.java b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/ResponseHeadersModification.java index 3aedccb..2fb9e2c 100644 --- a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/ResponseHeadersModification.java +++ b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/ResponseHeadersModification.java @@ -26,7 +26,7 @@ @Configuration(proxyBeanMethods = false) @ConditionalOnProperty(value = "spring.ai.openai.api-key", havingValue = "demo") -public class ResponseHeadersModification { +class ResponseHeadersModification { private static final Logger LOGGER = LoggerFactory.getLogger(ResponseHeadersModification.class); diff --git a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/SwaggerConfig.java b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/SwaggerConfig.java index a949602..18a1dc1 100644 --- a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/SwaggerConfig.java +++ b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/SwaggerConfig.java @@ -7,4 +7,4 @@ @Configuration(proxyBeanMethods = false) @OpenAPIDefinition(info = @Info(title = "rag-springai-openai-llm", version = "v1.0.0"), servers = @Server(url = "/")) -public class SwaggerConfig {} +class SwaggerConfig {} diff --git a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/AiController.java b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/AiController.java index 1945559..5795593 100644 --- a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/AiController.java +++ b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/AiController.java @@ -13,7 +13,7 @@ @RestController @RequestMapping("/api/ai") @Validated -public class AiController { +class AiController { private final AIChatService aiChatService;