Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename csv-chatbot to sql-chatbot #605

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions docs/modules/ROOT/pages/csv.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ When loading a CSV file, the process involves:
2. Ingesting the set of documents using an appropriate *document splitter*.
3. Storing the documents in the database.

You can find a complete example in the https://github.com/quarkiverse/quarkus-langchain4j/tree/main/samples/csv-chatbot[GitHub Repository].
You can find a complete example in the https://github.com/quarkiverse/quarkus-langchain4j/tree/main/samples/sql-chatbot[GitHub Repository].

== From CSV to Documents

Expand Down Expand Up @@ -92,38 +92,44 @@ var ingestor = EmbeddingStoreIngestor.builder()
ingestor.ingest(documents);
----

== Implementing the Retriever
== Implementing the Retrieval augmentor

With the documents ingested, you can now implement the retriever:
With the documents ingested, you can now implement the retrieval augmentor:

[source, java]
----
package io.quarkiverse.langchain4j.sample.chatbot;

import java.util.List;
import java.util.function.Supplier;

import jakarta.enterprise.context.ApplicationScoped;

import dev.langchain4j.data.segment.TextSegment;
import dev.langchain4j.model.embedding.EmbeddingModel;
import dev.langchain4j.retriever.EmbeddingStoreRetriever;
import dev.langchain4j.retriever.Retriever;
import io.quarkiverse.langchain4j.redis.RedisEmbeddingStore;
import dev.langchain4j.rag.DefaultRetrievalAugmentor;
import dev.langchain4j.rag.RetrievalAugmentor;
import dev.langchain4j.rag.content.retriever.EmbeddingStoreContentRetriever;
import dev.langchain4j.store.embedding.EmbeddingStore;

@ApplicationScoped
public class RetrieverExample implements Retriever<TextSegment> {
public class AugmentorExample implements Supplier<RetrievalAugmentor> {

private final EmbeddingStoreRetriever retriever;
private final EmbeddingStoreContentRetriever retriever;

RetrieverExample(RedisEmbeddingStore store, EmbeddingModel model) {
// Limit the number of documents to avoid exceeding the context size.
retriever = EmbeddingStoreRetriever.from(store, model, 10);
AugmentorExample(EmbeddingStore store, EmbeddingModel model) {
retriever = EmbeddingStoreContentRetriever.builder()
.embeddingModel(model)
.embeddingStore(store)
.maxResults(10)
.build();
}

@Override
public List<TextSegment> findRelevant(String s) {
return retriever.findRelevant(s);
public RetrievalAugmentor get() {
return DefaultRetrievalAugmentor.builder()
.contentRetriever(retriever)
.build();
}
}

----

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
<module>samples/fraud-detection</module>
<module>samples/chatbot</module>
<module>samples/chatbot-easy-rag</module>
<module>samples/csv-chatbot</module>
<module>samples/sql-chatbot</module>
</modules>
</profile>
</profiles>
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions samples/csv-chatbot/pom.xml → samples/sql-chatbot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<modelVersion>4.0.0</modelVersion>

<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-sample-csv-chatbot</artifactId>
<name>Quarkus LangChain4j - Sample - Chatbot &amp; RAG loading a CSV file</name>
<artifactId>quarkus-langchain4j-sample-sql-chatbot</artifactId>
<name>Quarkus LangChain4j - Sample - Chatbot &amp; RAG from a SQL database</name>
<version>1.0-SNAPSHOT</version>

<properties>
Expand Down
Loading