diff --git a/README.md b/README.md index 9bda899..a17c9b0 100644 --- a/README.md +++ b/README.md @@ -144,10 +144,6 @@ Question answering with documents using different RAG flows (with Ollama and PGV * **[Naive](https://github.com/ThomasVitale/llm-apps-java-spring-ai/tree/main/rag/rag-sequential/rag-naive)** * **[Advanced](https://github.com/ThomasVitale/llm-apps-java-spring-ai/tree/main/rag/rag-sequential/rag-advanced)** -### ❔ Conditional RAG - -* **[Conditional](https://github.com/ThomasVitale/llm-apps-java-spring-ai/tree/main/rag/rag-conditional)** - ### 🌳 Branching RAG * **[Branching](https://github.com/ThomasVitale/llm-apps-java-spring-ai/tree/main/rag/rag-branching)** diff --git a/observability/models/observability-models-openai/src/main/java/com/thomasvitale/ai/spring/ChatController.java b/observability/models/observability-models-openai/src/main/java/com/thomasvitale/ai/spring/ChatController.java index 60626de..e86479e 100644 --- a/observability/models/observability-models-openai/src/main/java/com/thomasvitale/ai/spring/ChatController.java +++ b/observability/models/observability-models-openai/src/main/java/com/thomasvitale/ai/spring/ChatController.java @@ -49,7 +49,7 @@ String chatProviderOptions(String question) { return chatClient .prompt(question) .options(OpenAiChatOptions.builder() - .withLogprobs(true) + .logprobs(true) .build()) .call() .content(); diff --git a/observability/models/observability-models-openai/src/main/java/com/thomasvitale/ai/spring/EmbeddingController.java b/observability/models/observability-models-openai/src/main/java/com/thomasvitale/ai/spring/EmbeddingController.java index d88d823..b8b2974 100644 --- a/observability/models/observability-models-openai/src/main/java/com/thomasvitale/ai/spring/EmbeddingController.java +++ b/observability/models/observability-models-openai/src/main/java/com/thomasvitale/ai/spring/EmbeddingController.java @@ -44,7 +44,7 @@ String embedGenericOptions(String query) { String embedProviderOptions(String query) { logger.info("Embedding with provider options: {}", query); var embeddings = embeddingModel.call(new EmbeddingRequest(List.of(query), OpenAiEmbeddingOptions.builder() - .withEncodingFormat("float") + .encodingFormat("float") .build())) .getResult().getOutput(); return "Size of the embedding vector: " + embeddings.length; diff --git a/observability/models/observability-models-openai/src/main/java/com/thomasvitale/ai/spring/ImageController.java b/observability/models/observability-models-openai/src/main/java/com/thomasvitale/ai/spring/ImageController.java index ad512d1..6458a48 100644 --- a/observability/models/observability-models-openai/src/main/java/com/thomasvitale/ai/spring/ImageController.java +++ b/observability/models/observability-models-openai/src/main/java/com/thomasvitale/ai/spring/ImageController.java @@ -26,8 +26,8 @@ class ImageController { String image(String message) { logger.info("Generating image: {}", message); var imageResponse = imageModel.call(new ImagePrompt(message, ImageOptionsBuilder.builder() - .withHeight(1024) - .withWidth(1024) + .height(1024) + .width(1024) .build())); return imageResponse.getResult().getOutput().getUrl(); } diff --git a/rag/rag-conditional/README.md b/rag/rag-conditional/README.md deleted file mode 100644 index b8e5415..0000000 --- a/rag/rag-conditional/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# Conditional RAG: Routing - -Ask questions about documents with LLMs via Ollama and PGVector. - -## Ollama - -The application consumes models from an [Ollama](https://ollama.ai) inference server. You can either run Ollama locally on your laptop, -or rely on the Testcontainers support in Spring Boot to spin up an Ollama service automatically. -If you choose the first option, make sure you have Ollama installed and running on your laptop. -Either way, Spring AI will take care of pulling the needed Ollama models when the application starts, -if they are not available yet on your machine. - -## Running the application - -The application relies on Testcontainers to provision automatically -a Grafana LGTM observability stack and a PGVector database. - -If you're using the native Ollama application, run the application as follows. - -```shell -./gradlew bootTestRun -``` - -If you want to rely on the native Testcontainers support in Spring Boot to spin up an Ollama service at startup time, -run the application as follows. - -```shell -./gradlew bootTestRun -Dspring.profiles.active=ollama-image -``` - -## Observability Platform - -Grafana is listening to port 3000. Check the application logs or your container runtime to find the port to which -is exposed to your localhost and access Grafana from http://localhost:. The credentials are `admin`/`admin`. - -The application is automatically configured to export logs, metrics, and traces to the Grafana LGTM platform via OpenTelemetry. -In Grafana, you can query the traces from the "Explore" page, selecting the "Tempo" data source. -You can also explore metrics in "Explore > Metrics" and logs in "Explore > Logs". - -## Calling the application - -> [!NOTE] -> These examples use the [httpie](https://httpie.io) CLI to send HTTP requests. - -Call the application that will use a chat model to answer your questions. - -### Query Routing: Keywords - -```shell -http --raw "Where in Italy is Lucio going on an adventure?" :8080/rag/routing-keywords -b --pretty none -``` diff --git a/rag/rag-conditional/build.gradle b/rag/rag-conditional/build.gradle deleted file mode 100644 index 38c41ef..0000000 --- a/rag/rag-conditional/build.gradle +++ /dev/null @@ -1,51 +0,0 @@ -plugins { - id 'java' - id 'org.springframework.boot' - id 'io.spring.dependency-management' -} - -group = 'com.thomasvitale' -version = '0.0.1-SNAPSHOT' - -java { - toolchain { - languageVersion = JavaLanguageVersion.of(23) - } -} - -repositories { - mavenCentral() - maven { url 'https://repo.spring.io/milestone' } - maven { url 'https://repo.spring.io/snapshot' } -} - -dependencies { - implementation platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${otelInstrumentationVersion}") - implementation platform("org.springframework.ai:spring-ai-bom:${springAiVersion}") - - implementation 'org.springframework.boot:spring-boot-starter-actuator' - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.ai:spring-ai-ollama-spring-boot-starter' - implementation 'org.springframework.ai:spring-ai-pgvector-store-spring-boot-starter' - implementation 'org.springframework.ai:spring-ai-markdown-document-reader' - - implementation 'io.micrometer:micrometer-tracing-bridge-otel' - implementation 'io.opentelemetry:opentelemetry-exporter-otlp' - implementation 'io.micrometer:micrometer-registry-otlp' - implementation 'net.ttddyy.observation:datasource-micrometer-spring-boot:1.0.5' - implementation 'io.opentelemetry.instrumentation:opentelemetry-logback-appender-1.0' - - testAndDevelopmentOnly 'org.springframework.boot:spring-boot-devtools' - - testImplementation 'org.springframework.boot:spring-boot-starter-test' - testImplementation 'org.springframework.boot:spring-boot-testcontainers' - testImplementation 'org.springframework.ai:spring-ai-spring-boot-testcontainers' - testImplementation 'org.springframework:spring-webflux' - testImplementation 'org.testcontainers:grafana' - testImplementation 'org.testcontainers:ollama' - testImplementation 'org.testcontainers:postgresql' -} - -tasks.named('test') { - useJUnitPlatform() -} diff --git a/rag/rag-conditional/src/main/java/com/thomasvitale/ai/spring/IngestionPipeline.java b/rag/rag-conditional/src/main/java/com/thomasvitale/ai/spring/IngestionPipeline.java deleted file mode 100644 index 7dc5d7f..0000000 --- a/rag/rag-conditional/src/main/java/com/thomasvitale/ai/spring/IngestionPipeline.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.thomasvitale.ai.spring; - -import jakarta.annotation.PostConstruct; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.ai.document.Document; -import org.springframework.ai.reader.markdown.MarkdownDocumentReader; -import org.springframework.ai.reader.markdown.config.MarkdownDocumentReaderConfig; -import org.springframework.ai.transformer.splitter.TokenTextSplitter; -import org.springframework.ai.vectorstore.VectorStore; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.io.Resource; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; - -@Component -class IngestionPipeline { - - private static final Logger logger = LoggerFactory.getLogger(IngestionPipeline.class); - - private final VectorStore vectorStore; - - @Value("classpath:documents/story1.md") - Resource file1; - - @Value("classpath:documents/story2.md") - Resource file2; - - IngestionPipeline(VectorStore vectorStore) { - this.vectorStore = vectorStore; - } - - @PostConstruct - void run() { - List documents = new ArrayList<>(); - - logger.info("Loading .md files as Documents"); - var markdownReader1 = new MarkdownDocumentReader(file1, MarkdownDocumentReaderConfig.builder() - .withAdditionalMetadata("location", "North Pole") - .build()); - documents.addAll(markdownReader1.get()); - var markdownReader2 = new MarkdownDocumentReader(file2, MarkdownDocumentReaderConfig.builder() - .withAdditionalMetadata("location", "Italy") - .build()); - documents.addAll(markdownReader2.get()); - - logger.info("Creating and storing Embeddings from Documents"); - vectorStore.add(new TokenTextSplitter().split(documents)); - } - -} diff --git a/rag/rag-conditional/src/main/java/com/thomasvitale/ai/spring/RagConditional.java b/rag/rag-conditional/src/main/java/com/thomasvitale/ai/spring/RagConditional.java deleted file mode 100644 index fb886f3..0000000 --- a/rag/rag-conditional/src/main/java/com/thomasvitale/ai/spring/RagConditional.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.thomasvitale.ai.spring; - -import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.event.ApplicationReadyEvent; -import org.springframework.context.ApplicationListener; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -public class RagConditional { - - public static void main(String[] args) { - SpringApplication.run(RagConditional.class, args); - } - - @Bean - ApplicationListener logbackOtelAppenderInitializer(OpenTelemetry openTelemetry) { - return _ -> OpenTelemetryAppender.install(openTelemetry); - } - -} diff --git a/rag/rag-conditional/src/main/java/com/thomasvitale/ai/spring/RagControllerRoutingKeywords.java b/rag/rag-conditional/src/main/java/com/thomasvitale/ai/spring/RagControllerRoutingKeywords.java deleted file mode 100644 index 0251fe9..0000000 --- a/rag/rag-conditional/src/main/java/com/thomasvitale/ai/spring/RagControllerRoutingKeywords.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.thomasvitale.ai.spring; - -import org.springframework.ai.chat.client.ChatClient; -import org.springframework.ai.chat.client.advisor.RetrievalAugmentationAdvisor; -import org.springframework.ai.rag.orchestration.routing.QueryRouter; -import org.springframework.ai.rag.retrieval.search.DocumentRetriever; -import org.springframework.ai.rag.retrieval.search.VectorStoreDocumentRetriever; -import org.springframework.ai.vectorstore.VectorStore; -import org.springframework.ai.vectorstore.filter.FilterExpressionBuilder; -import org.springframework.core.task.TaskExecutor; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -import java.util.ArrayList; -import java.util.List; - -@RestController -public class RagControllerRoutingKeywords { - - private final ChatClient chatClient; - private final RetrievalAugmentationAdvisor retrievalAugmentationAdvisor; - - public RagControllerRoutingKeywords(ChatClient.Builder chatClientBuilder, TaskExecutor taskExecutor, VectorStore vectorStore) { - this.chatClient = chatClientBuilder.build(); - - var northPoleDocumentRetriever = VectorStoreDocumentRetriever.builder() - .vectorStore(vectorStore) - .similarityThreshold(0.50) - .filterExpression(() -> new FilterExpressionBuilder() - .eq("location", "North Pole") - .build()) - .build(); - - var italyDocumentRetriever = VectorStoreDocumentRetriever.builder() - .vectorStore(vectorStore) - .similarityThreshold(0.50) - .filterExpression(new FilterExpressionBuilder() - .eq("location", "Italy") - .build()) - .build(); - - QueryRouter queryRouter = query -> { - List documentRetrievers = new ArrayList<>(); - if (query.text().contains("North Pole")) { - documentRetrievers.add(northPoleDocumentRetriever); - } else if (query.text().contains("Italy")) { - documentRetrievers.add(italyDocumentRetriever); - } else { - documentRetrievers.add(northPoleDocumentRetriever); - documentRetrievers.add(italyDocumentRetriever); - } - return documentRetrievers; - }; - - this.retrievalAugmentationAdvisor = RetrievalAugmentationAdvisor.builder() - .queryRouter(queryRouter) - .taskExecutor(taskExecutor) - .build(); - } - - @PostMapping("/rag/routing-keywords") - String rag(@RequestBody String input) { - return chatClient.prompt() - .advisors(retrievalAugmentationAdvisor) - .user(input) - .call() - .content(); - } - -} diff --git a/rag/rag-conditional/src/main/resources/application.yml b/rag/rag-conditional/src/main/resources/application.yml deleted file mode 100644 index 68366bf..0000000 --- a/rag/rag-conditional/src/main/resources/application.yml +++ /dev/null @@ -1,52 +0,0 @@ -spring: - application: - name: rag-advanced - ai: - chat: - observations: - include-completion: true - include-prompt: true - ollama: - init: - pull-model-strategy: when_missing - chat: - options: - model: qwen2.5 - num-ctx: 4096 - embedding: - options: - model: nomic-embed-text - vectorstore: - observations: - include-query-response: true - pgvector: - initialize-schema: true - dimensions: 768 - index-type: hnsw - http: - client: - read-timeout: 60s - threads: - virtual: - enabled: true - -logging: - level: - org.springframework.ai.rag: debug - -management: - endpoints: - web: - exposure: - include: "*" - metrics: - tags: - service.name: ${spring.application.name} - tracing: - sampling: - probability: 1.0 - otlp: - logging: - endpoint: "http://localhost:4318/v1/logs" - tracing: - endpoint: "http://localhost:4318/v1/traces" diff --git a/rag/rag-conditional/src/main/resources/documents/story1.md b/rag/rag-conditional/src/main/resources/documents/story1.md deleted file mode 100644 index e9174fd..0000000 --- a/rag/rag-conditional/src/main/resources/documents/story1.md +++ /dev/null @@ -1,42 +0,0 @@ -# The Adventures of Iorek and Pingu - -Iorek was a little polar bear who lived in the Arctic circle. He loved to explore the snowy landscape and -dreamt of one day going on an adventure around the North Pole. One day, he met a penguin named Pingu who -was on a similar quest. They quickly became friends and decided to embark on their journey together. - -Iorek and Pingu set off early in the morning, eager to cover as much ground as possible before nightfall. -The air was crisp and cold, and the snow crunched under their paws as they walked. They chatted excitedly -about their dreams and aspirations, and Iorek told Pingu about his desire to see the Northern Lights. - -As they journeyed onward, they encountered a group of playful seals who were sliding and jumping in the -snow. Iorek and Pingu watched in delight as the seals frolicked and splashed in the water. They even tried -to join in, but their paws kept slipping and they ended up sliding on their stomachs instead. - -After a few hours of walking, Iorek and Pingu came across a cave hidden behind a wall of snow. They -cautiously entered the darkness, their eyes adjusting to the dim light inside. The cave was filled with -glittering ice formations that sparkled like diamonds in the flickering torchlight. - -As they continued their journey, Iorek and Pingu encountered a group of walruses who were lounging on the -ice. They watched in amazement as the walruses lazily rolled over and exposed their tusks for a good -scratch. Pingu even tried to imitate them, but ended up looking more like a clumsy seal than a walrus. - -As the sun began to set, Iorek and Pingu found themselves at the edge of a vast, frozen lake. They gazed -out across the glassy surface, mesmerized by the way the ice glinted in the fading light. They could see -the faint outline of a creature moving beneath the surface, and their hearts raced with excitement. - -Suddenly, a massive narwhal burst through the ice and into the air, its ivory tusk glistening in the -sunset. Iorek and Pingu watched in awe as it soared overhead, its cries echoing across the lake. They felt -as though they were witnessing a magical moment, one that would stay with them forever. - -As the night drew in, Iorek and Pingu settled down to rest in their makeshift camp. They huddled together -for warmth, gazing up at the starry sky above. They chatted about all they had seen and experienced during -their adventure, and Iorek couldn't help but feel grateful for the new friend he had made. - -The next morning, Iorek and Pingu set off once again, determined to explore every inch of the North Pole. -They stumbled upon a hidden cave filled with glittering crystals that sparkled like diamonds in the -sunlight. They marveled at their beauty before continuing on their way. - -As they journeyed onward, Iorek and Pingu encountered many more wonders and adventures. They met a group -of playful reindeer who showed them how to pull sledges across the snow, and even caught a glimpse of the -mythical Loch Ness Monster lurking beneath the icy waters. In the end, their adventure around the North -Pole had been an unforgettable experience, one that they would treasure forever. diff --git a/rag/rag-conditional/src/main/resources/documents/story2.md b/rag/rag-conditional/src/main/resources/documents/story2.md deleted file mode 100644 index 53d1203..0000000 --- a/rag/rag-conditional/src/main/resources/documents/story2.md +++ /dev/null @@ -1,58 +0,0 @@ -# Lucio and Balosso explore the Alps - -## Chapter 1: An Unlikely Friendship -Lucio was a little wolf who lived in the Italian Alps. He loved to explore the rugged landscape and dreamt -of one day going on an adventure around the mountains. One day, he met a brown bear named Balosso who was -on a similar quest. They quickly became friends and decided to embark on their journey together. - -## Chapter 2: The Journey Begins -Lucio and Balosso set off early in the morning, eager to cover as much ground as possible before -nightfall. The air was crisp and cool, and the sun shone brightly overhead. They chatted excitedly about -their dreams and aspirations, and Lucio told Balosso about his desire to climb to the top of the highest -peak in the Alps. - -## Chapter 3: Playful Encounters -As they journeyed onward, they encountered a group of playful marmots who were scampering across the rocky -terrain. Lucio and Balosso watched in delight as the marmots frolicked and chased each other, their paws -pattering on the stone. They even tried to join in, but their paws kept slipping and they ended up -tumbling onto their backsides. - -## Chapter 4: The Hidden Glacier -After a few hours of walking, Lucio and Balosso came across a hidden glacier nestled between two towering -peaks. They cautiously approached the icy surface, their breath misting in the cold air. The glacier was -covered in intricate patterns and colors, shimmering like a shimmering jewel in the sunlight. - -## Chapter 5: Soaring Eagles -As they continued their journey, Lucio and Balosso encountered a group of majestic eagles soaring -overhead. They watched in awe as the eagles swooped and dived, their wings spread wide against the blue -sky. Lucio even tried to imitate them, but ended up flapping his ears instead of wings. - -## Chapter 6: The Highest Peak -As the sun began to set, Lucio and Balosso found themselves at the foot of the highest peak in the Alps. -They gazed upwards in awe, their hearts pounding with excitement. They could see the faint outline of a -summit visible through the misty veil that surrounded the mountain. - -## Chapter 7: The Climb -Lucio and Balosso carefully climbed the steep slope, their claws digging into the rocky surface. The air -grew colder and thinner as they ascended, but they pressed onward, determined to reach the top. Finally, -they reached the summit, where they found a stunning view of the Italian Alps stretching out before them. - -## Chapter 8: Summit Success -As they gazed out across the landscape, Lucio and Balosso felt an overwhelming sense of pride and -accomplishment. They had faced many challenges along the way, but their friendship had carried them -through. They even spotted a group of rare alpine ibex grazing on the distant slopes, adding to the -adventure's magic. - -## Chapter 9: The Journey Home -As night began to fall, Lucio and Balosso made their way back down the mountain, their paws sore but their -spirits high. They couldn't wait to tell their friends and family about their amazing adventure around the -Italian Alps. Even as they drifted off to sleep, visions of the stunning landscape danced in their minds. - -## Chapter 10: New Discoveries -The next morning, Lucio and Balosso set off once again, eager to explore every inch of the mountain range. -They stumbled upon a hidden valley filled with sparkling streams and towering trees, and even caught a -glimpse of a rare, elusive snow leopard lurking in the shadows. - -## Epilogue: Unforgettable Memories -In the end, their adventure around the Italian Alps had been an unforgettable experience, -one that they would treasure forever. diff --git a/rag/rag-conditional/src/main/resources/logback-spring.xml b/rag/rag-conditional/src/main/resources/logback-spring.xml deleted file mode 100644 index 16842e9..0000000 --- a/rag/rag-conditional/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - true - true - true - - - - - - - \ No newline at end of file diff --git a/rag/rag-conditional/src/test/java/com/thomasvitale/ai/spring/RagConditionalTests.java b/rag/rag-conditional/src/test/java/com/thomasvitale/ai/spring/RagConditionalTests.java deleted file mode 100644 index 6e5db54..0000000 --- a/rag/rag-conditional/src/test/java/com/thomasvitale/ai/spring/RagConditionalTests.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.thomasvitale.ai.spring; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -@Disabled -class RagConditionalTests { - - @Test - void contextLoads() { - } - -} diff --git a/rag/rag-conditional/src/test/java/com/thomasvitale/ai/spring/TestRagConditional.java b/rag/rag-conditional/src/test/java/com/thomasvitale/ai/spring/TestRagConditional.java deleted file mode 100644 index 2bff9fa..0000000 --- a/rag/rag-conditional/src/test/java/com/thomasvitale/ai/spring/TestRagConditional.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.thomasvitale.ai.spring; - -import org.springframework.boot.SpringApplication; - -public class TestRagConditional { - - public static void main(String[] args) { - SpringApplication.from(RagConditional::main).with(TestcontainersConfiguration.class).run(args); - } - -} diff --git a/rag/rag-conditional/src/test/java/com/thomasvitale/ai/spring/TestcontainersConfiguration.java b/rag/rag-conditional/src/test/java/com/thomasvitale/ai/spring/TestcontainersConfiguration.java deleted file mode 100644 index 45cc8df..0000000 --- a/rag/rag-conditional/src/test/java/com/thomasvitale/ai/spring/TestcontainersConfiguration.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.thomasvitale.ai.spring; - -import org.springframework.boot.devtools.restart.RestartScope; -import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Profile; -import org.testcontainers.containers.PostgreSQLContainer; -import org.testcontainers.grafana.LgtmStackContainer; -import org.testcontainers.ollama.OllamaContainer; - -import java.time.Duration; - -@TestConfiguration(proxyBeanMethods = false) -class TestcontainersConfiguration { - - @Bean - @RestartScope - @ServiceConnection - PostgreSQLContainer pgvectorContainer() { - return new PostgreSQLContainer<>("pgvector/pgvector:pg17"); - } - - @Bean - @RestartScope - @ServiceConnection - LgtmStackContainer lgtmContainer() { - return new LgtmStackContainer("grafana/otel-lgtm:0.8.0") - .withStartupTimeout(Duration.ofMinutes(2)) - .withReuse(true); - } - - @Bean - @Profile("ollama-image") - @RestartScope - @ServiceConnection - OllamaContainer ollama() { - return new OllamaContainer("ollama/ollama").withReuse(true); - } - -} diff --git a/settings.gradle b/settings.gradle index ede1cd5..65e5ca4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -53,7 +53,6 @@ include 'patterns:function-calling:function-calling-ollama' include 'patterns:function-calling:function-calling-openai' include 'rag:rag-branching' -include 'rag:rag-conditional' include 'rag:rag-sequential:rag-advanced' include 'rag:rag-sequential:rag-naive' diff --git a/use-cases/semantic-search/src/main/java/com/thomasvitale/ai/spring/SemanticSearchController.java b/use-cases/semantic-search/src/main/java/com/thomasvitale/ai/spring/SemanticSearchController.java index 4e04bb7..3fba2c8 100644 --- a/use-cases/semantic-search/src/main/java/com/thomasvitale/ai/spring/SemanticSearchController.java +++ b/use-cases/semantic-search/src/main/java/com/thomasvitale/ai/spring/SemanticSearchController.java @@ -19,7 +19,7 @@ class SemanticSearchController { @PostMapping("/semantic-search") List semanticSearch(@RequestBody String query) { - return vectorStore.similaritySearch(SearchRequest.query(query).withTopK(3)) + return vectorStore.similaritySearch(SearchRequest.builder().query(query).topK(3).build()) .stream() .map(document -> new InstrumentNote(document.getText())) .toList();