From b67029224b8eb8eba9d3d77ff9c63d0102a1b1aa Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 3 Jan 2025 16:30:22 +0000 Subject: [PATCH 1/3] polish openAIKey --- .vscode/launch.json | 7 +++++++ .../com/learning/openai/LangChain4JAIServicesDemo.java | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 3b80028..f385298 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,5 +1,12 @@ { "configurations": [ + { + "type": "java", + "name": "LangChain4JAIServicesDemo", + "request": "launch", + "mainClass": "com.learning.openai.LangChain4JAIServicesDemo", + "projectName": "playground-langchain4j" + }, { "type": "java", "name": "LangChain4JObservabilityDemo", diff --git a/playground-langchain4j/src/main/java/com/learning/openai/LangChain4JAIServicesDemo.java b/playground-langchain4j/src/main/java/com/learning/openai/LangChain4JAIServicesDemo.java index 2dad94e..41bb575 100644 --- a/playground-langchain4j/src/main/java/com/learning/openai/LangChain4JAIServicesDemo.java +++ b/playground-langchain4j/src/main/java/com/learning/openai/LangChain4JAIServicesDemo.java @@ -8,15 +8,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Optional; + public class LangChain4JAIServicesDemo { private static final Logger LOGGER = LoggerFactory.getLogger(LangChain4JAIServicesDemo.class); public static void main(String[] args) { - // String openAIKey = System.getenv("OPEN_AI_KEY"); - // OpenAiChatModel openAiChatModel = OpenAiChatModel.withApiKey("demo"); + String openAIKey = System.getenv("OPEN_AI_KEY"); OpenAiChatModel openAiChatModel = OpenAiChatModel.builder() - .apiKey("demo") + .apiKey(Optional.ofNullable(openAIKey).orElse("demo")) .modelName(OpenAiChatModelName.GPT_4_O_MINI) .logRequests(false) .logResponses(false) From 3fc728dc33636a5507b9a9be979488faf541f697 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 3 Jan 2025 16:35:33 +0000 Subject: [PATCH 2/3] Use latest way to set factory --- .../src/main/java/com/example/ai/config/LoggingConfig.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chatmodel-springai/src/main/java/com/example/ai/config/LoggingConfig.java b/chatmodel-springai/src/main/java/com/example/ai/config/LoggingConfig.java index 7aa3740..2d50776 100644 --- a/chatmodel-springai/src/main/java/com/example/ai/config/LoggingConfig.java +++ b/chatmodel-springai/src/main/java/com/example/ai/config/LoggingConfig.java @@ -7,6 +7,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder; import org.springframework.boot.web.client.RestClientCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -14,7 +15,6 @@ import org.springframework.http.MediaType; import org.springframework.http.client.BufferingClientHttpRequestFactory; import org.springframework.http.client.ClientHttpResponse; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.util.StreamUtils; @Configuration(proxyBeanMethods = false) @@ -26,7 +26,8 @@ public class LoggingConfig { @Bean RestClientCustomizer restClientCustomizer() { return restClientBuilder -> restClientBuilder - .requestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory())) + .requestFactory(new BufferingClientHttpRequestFactory( + ClientHttpRequestFactoryBuilder.httpComponents().build())) .requestInterceptor((request, body, execution) -> { logRequest(request, body); ClientHttpResponse response = execution.execute(request, body); From b3136559356d617195dc6ad3c11a1e6380e00982 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 21:45:07 +0530 Subject: [PATCH 3/3] fix(deps): update dependency org.springdoc:springdoc-openapi-starter-webmvc-ui to v2.8.1 (#137) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- chatbot/chatbot-ollama-springai/pom.xml | 2 +- chatmodel-springai/pom.xml | 2 +- embeddingstores/neo4j-springai/pom.xml | 2 +- embeddingstores/pgvector-langchain4j/pom.xml | 2 +- embeddingstores/pgvector-springai/pom.xml | 2 +- rag/rag-langchain4j-AllMiniLmL6V2-llm/pom.xml | 2 +- rag/rag-springai-ollama-llm/pom.xml | 2 +- rag/rag-springai-openai-llm/pom.xml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/chatbot/chatbot-ollama-springai/pom.xml b/chatbot/chatbot-ollama-springai/pom.xml index c72a303..ea00380 100644 --- a/chatbot/chatbot-ollama-springai/pom.xml +++ b/chatbot/chatbot-ollama-springai/pom.xml @@ -42,7 +42,7 @@ org.springdoc springdoc-openapi-starter-webmvc-ui - 2.7.0 + 2.8.1 diff --git a/chatmodel-springai/pom.xml b/chatmodel-springai/pom.xml index be995b2..e97e3ce 100644 --- a/chatmodel-springai/pom.xml +++ b/chatmodel-springai/pom.xml @@ -47,7 +47,7 @@ org.springdoc springdoc-openapi-starter-webmvc-ui - 2.7.0 + 2.8.1 diff --git a/embeddingstores/neo4j-springai/pom.xml b/embeddingstores/neo4j-springai/pom.xml index 98e4a92..dbe91ae 100644 --- a/embeddingstores/neo4j-springai/pom.xml +++ b/embeddingstores/neo4j-springai/pom.xml @@ -43,7 +43,7 @@ org.springdoc springdoc-openapi-starter-webmvc-ui - 2.7.0 + 2.8.1 diff --git a/embeddingstores/pgvector-langchain4j/pom.xml b/embeddingstores/pgvector-langchain4j/pom.xml index dfea680..b6cefaf 100644 --- a/embeddingstores/pgvector-langchain4j/pom.xml +++ b/embeddingstores/pgvector-langchain4j/pom.xml @@ -48,7 +48,7 @@ org.springdoc springdoc-openapi-starter-webmvc-ui - 2.7.0 + 2.8.1 diff --git a/embeddingstores/pgvector-springai/pom.xml b/embeddingstores/pgvector-springai/pom.xml index c1a67e2..dba5535 100644 --- a/embeddingstores/pgvector-springai/pom.xml +++ b/embeddingstores/pgvector-springai/pom.xml @@ -44,7 +44,7 @@ org.springdoc springdoc-openapi-starter-webmvc-ui - 2.7.0 + 2.8.1 diff --git a/rag/rag-langchain4j-AllMiniLmL6V2-llm/pom.xml b/rag/rag-langchain4j-AllMiniLmL6V2-llm/pom.xml index 3fb3ac8..736af91 100644 --- a/rag/rag-langchain4j-AllMiniLmL6V2-llm/pom.xml +++ b/rag/rag-langchain4j-AllMiniLmL6V2-llm/pom.xml @@ -67,7 +67,7 @@ org.springdoc springdoc-openapi-starter-webmvc-ui - 2.7.0 + 2.8.1 diff --git a/rag/rag-springai-ollama-llm/pom.xml b/rag/rag-springai-ollama-llm/pom.xml index 1730d20..6088efe 100644 --- a/rag/rag-springai-ollama-llm/pom.xml +++ b/rag/rag-springai-ollama-llm/pom.xml @@ -53,7 +53,7 @@ org.springdoc springdoc-openapi-starter-webmvc-ui - 2.7.0 + 2.8.1 diff --git a/rag/rag-springai-openai-llm/pom.xml b/rag/rag-springai-openai-llm/pom.xml index 801c3be..3cf8277 100644 --- a/rag/rag-springai-openai-llm/pom.xml +++ b/rag/rag-springai-openai-llm/pom.xml @@ -56,7 +56,7 @@ org.springdoc springdoc-openapi-starter-webmvc-ui - 2.7.0 + 2.8.1