From 0d932ba7447d81cdfae3be69fb67b3e620747868 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Thu, 30 May 2024 07:28:33 +0000 Subject: [PATCH] feat : upgrade to 1.0.0-M1 --- rag/rag-springai-openai-llm/pom.xml | 2 +- .../ai/llmragwithspringai/service/AIChatService.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rag/rag-springai-openai-llm/pom.xml b/rag/rag-springai-openai-llm/pom.xml index d0f496c..2977269 100644 --- a/rag/rag-springai-openai-llm/pom.xml +++ b/rag/rag-springai-openai-llm/pom.xml @@ -16,7 +16,7 @@ 21 - 0.8.1 + 1.0.0-M1 2.43.0 diff --git a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java index 403e5cb..3a06340 100644 --- a/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java +++ b/rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java @@ -3,11 +3,11 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import org.springframework.ai.chat.ChatClient; -import org.springframework.ai.chat.ChatResponse; -import org.springframework.ai.chat.Generation; +import org.springframework.ai.chat.client.ChatClient; import org.springframework.ai.chat.messages.Message; import org.springframework.ai.chat.messages.UserMessage; +import org.springframework.ai.chat.model.ChatResponse; +import org.springframework.ai.chat.model.Generation; import org.springframework.ai.chat.prompt.Prompt; import org.springframework.ai.chat.prompt.SystemPromptTemplate; import org.springframework.ai.document.Document; @@ -40,8 +40,8 @@ with one player from the fielding team (the bowler) bowling the ball towards the private final ChatClient aiClient; private final VectorStore vectorStore; - public AIChatService(ChatClient aiClient, VectorStore vectorStore) { - this.aiClient = aiClient; + public AIChatService(ChatClient.Builder chatClientBuilder, VectorStore vectorStore) { + this.aiClient = chatClientBuilder.build(); this.vectorStore = vectorStore; } @@ -58,7 +58,7 @@ public String chat(String searchQuery) { OpenAiChatOptions chatOptions = OpenAiChatOptions.builder().withFunction("currentDateFunction").build(); Prompt prompt = new Prompt(List.of(systemMessage, userMessage), chatOptions); - ChatResponse aiResponse = aiClient.call(prompt); + ChatResponse aiResponse = aiClient.prompt(prompt).call().chatResponse(); Generation generation = aiResponse.getResult(); return (generation != null) ? generation.getOutput().getContent() : ""; }