From 8590993098843bc25b7f397bed30caeec683cda8 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Tue, 24 Dec 2024 14:04:56 +0000 Subject: [PATCH] upgrade docker --- .../docker/docker-compose.yml | 31 +++++++++++++++---- .../service/AIChatService.java | 18 ++--------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/rag/rag-springai-ollama-llm/docker/docker-compose.yml b/rag/rag-springai-ollama-llm/docker/docker-compose.yml index 928f97c..d7dca73 100644 --- a/rag/rag-springai-ollama-llm/docker/docker-compose.yml +++ b/rag/rag-springai-ollama-llm/docker/docker-compose.yml @@ -1,14 +1,33 @@ services: ollama: - image: langchain4j/ollama-llama3:latest + image: langchain4j/ollama-mistral:latest ports: - '11434:11434' - redis-stack: - image: redis/redis-stack-server - ports: - - '6379:6379' + + postgresqldb: + container_name: postgresqldb + image: pgvector/pgvector:pg17 + extra_hosts: [ 'host.docker.internal:host-gateway' ] + restart: always + environment: + - POSTGRES_USER=appuser + - POSTGRES_PASSWORD=secret + - POSTGRES_DB=appdb + - PGPASSWORD=secret + logging: + options: + max-size: 10m + max-file: "3" + ports: + - '5432:5432' + healthcheck: + test: "pg_isready -U appuser -d appdb" + interval: 2s + timeout: 20s + retries: 10 + lgtm-stack: - image: grafana/otel-lgtm:0.8.0 + image: grafana/otel-lgtm:0.8.1 extra_hosts: ['host.docker.internal:host-gateway'] container_name: lgtm-stack environment: diff --git a/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java b/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java index addb5a4..44e8f18 100644 --- a/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java +++ b/rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java @@ -4,7 +4,6 @@ import org.slf4j.LoggerFactory; import org.springframework.ai.chat.client.ChatClient; import org.springframework.ai.chat.client.advisor.RetrievalAugmentationAdvisor; -import org.springframework.ai.chat.prompt.AssistantPromptTemplate; import org.springframework.ai.rag.generation.augmentation.ContextualQueryAugmenter; import org.springframework.ai.rag.retrieval.search.VectorStoreDocumentRetriever; import org.springframework.ai.vectorstore.VectorStore; @@ -15,17 +14,6 @@ public class AIChatService { private static final Logger LOGGER = LoggerFactory.getLogger(AIChatService.class); - private static final String template = - """ - You are a helpful assistant, conversing with a user about the subjects contained in a set of documents. - Use the information from the DOCUMENTS section to provide accurate answers. If unsure or if the answer - isn't found in the DOCUMENTS section, simply state that you don't know the answer. - - DOCUMENTS: - {query} - - """; - private final ChatClient aiClient; public AIChatService(ChatClient.Builder builder, VectorStore vectorStore) { @@ -35,10 +23,8 @@ public AIChatService(ChatClient.Builder builder, VectorStore vectorStore) { .similarityThreshold(0.50) .build(); - var queryAugmenter = ContextualQueryAugmenter.builder() - .promptTemplate(new AssistantPromptTemplate(template)) - .allowEmptyContext(true) - .build(); + var queryAugmenter = + ContextualQueryAugmenter.builder().allowEmptyContext(true).build(); RetrievalAugmentationAdvisor retrievalAugmentationAdvisor = RetrievalAugmentationAdvisor.builder() .documentRetriever(documentRetriever)