Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartisk committed Nov 28, 2023
1 parent 3221aca commit cd5aae7
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import dev.langchain4j.data.document.Document;
import dev.langchain4j.model.embedding.EmbeddingModel;
import dev.langchain4j.store.embedding.EmbeddingStore;
import dev.langchain4j.store.embedding.EmbeddingStoreIngestor;
import io.quarkiverse.langchain4j.chroma.ChromaEmbeddingStore;

@ApplicationScoped
public class IngestorExampleWithChroma {
Expand All @@ -20,7 +20,7 @@ public class IngestorExampleWithChroma {
* The bean is provided by the quarkus-langchain4j-chroma extension.
*/
@Inject
EmbeddingStore store;
ChromaEmbeddingStore store;

/**
* The embedding model (how is computed the vector of a document).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.quarkiverse.langchain4j.samples;

import static dev.langchain4j.data.document.splitter.DocumentSplitters.recursive;

import java.util.List;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

import dev.langchain4j.data.document.Document;
import dev.langchain4j.model.embedding.EmbeddingModel;
import dev.langchain4j.store.embedding.EmbeddingStoreIngestor;
import io.quarkiverse.langchain4j.pinecone.PineconeEmbeddingStore;

@ApplicationScoped
public class IngestorExampleWithPinecone {

/**
* The embedding store (the database).
* The bean is provided by the quarkus-langchain4j-pinecone extension.
*/
@Inject
PineconeEmbeddingStore store;

/**
* The embedding model (how is computed the vector of a document).
* The bean is provided by the LLM (like openai) extension.
*/
@Inject
EmbeddingModel embeddingModel;

public void ingest(List<Document> documents) {
EmbeddingStoreIngestor ingestor = EmbeddingStoreIngestor.builder()
.embeddingStore(store)
.embeddingModel(embeddingModel)
.documentSplitter(recursive(500, 0))
.build();
// Warning - this can take a long time...
ingestor.ingest(documents);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@

import dev.langchain4j.data.document.Document;
import dev.langchain4j.model.embedding.EmbeddingModel;
import dev.langchain4j.store.embedding.EmbeddingStore;
import dev.langchain4j.store.embedding.EmbeddingStoreIngestor;
import io.quarkiverse.langchain4j.redis.RedisEmbeddingStore;

@ApplicationScoped
public class IngestorExample {
public class IngestorExampleWithRedis {

/**
* The embedding store (the database).
* The bean is provided by the quarkus-langchain4j-redis extension.
*/
@Inject
EmbeddingStore store;
RedisEmbeddingStore store;

/**
* The embedding model (how is computed the vector of a document).
Expand Down
14 changes: 14 additions & 0 deletions docs/modules/ROOT/pages/pinecone-store.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ To make use of the Pinecone document store, you'll need to include the following
</dependency>
----

The required configuration properties to make the extension work are
`quarkus.langchain4j.pinecone.api-key`,
`quarkus.langchain4j.pinecone.environment`,
`quarkus.langchain4j.pinecone.index-name`, and
`quarkus.langchain4j.pinecone.project-id`. The specified index will be
created if it doesn't exist yet.

Upon installing the extension, you can utilize the Pinecone embedding store using the following code:

[source,java]
----
include::{examples-dir}/io/quarkiverse/langchain4j/samples/IngestorExampleWithPinecone.java[]
----

== Configuration Settings

Customize the behavior of the extension by exploring various configuration options:
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/redis-store.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Upon installing the extension, you can utilize the Redis document store using th

[source,java]
----
include::{examples-dir}/io/quarkiverse/langchain4j/samples/IngestorExample.java[]
include::{examples-dir}/io/quarkiverse/langchain4j/samples/IngestorExampleWithRedis.java[]
----

== Configuration Settings
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/retrievers.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The following code demonstrates document ingestion in a Redis database:

[source,java]
----
include::{examples-dir}/io/quarkiverse/langchain4j/samples/IngestorExample.java[]
include::{examples-dir}/io/quarkiverse/langchain4j/samples/IngestorExampleWithRedis.java[]
----

Adjust the `documentSplitter` parameter based on the data structure.
Expand Down
60 changes: 30 additions & 30 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@
<artifactId>quarkus-langchain4j-openai</artifactId>
<version>${project.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.quarkiverse.langchain4j</groupId>-->
<!-- <artifactId>quarkus-langchain4j-hugging-face</artifactId>-->
<!-- <version>${project.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-hugging-face</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-redis</artifactId>
<version>${project.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.quarkiverse.langchain4j</groupId>-->
<!-- <artifactId>quarkus-langchain4j-chroma</artifactId>-->
<!-- <version>${project.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.quarkiverse.langchain4j</groupId>-->
<!-- <artifactId>quarkus-langchain4j-pinecone</artifactId>-->
<!-- <version>${project.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-chroma</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-pinecone</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Make sure the doc is built after the other artifacts -->
<dependency>
Expand All @@ -55,21 +55,21 @@
<artifactId>quarkus-langchain4j-redis-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.quarkiverse.langchain4j</groupId>-->
<!-- <artifactId>quarkus-langchain4j-chroma-deployment</artifactId>-->
<!-- <version>${project.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.quarkiverse.langchain4j</groupId>-->
<!-- <artifactId>quarkus-langchain4j-pinecone-deployment</artifactId>-->
<!-- <version>${project.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.quarkiverse.langchain4j</groupId>-->
<!-- <artifactId>quarkus-langchain4j-hugging-face-deployment</artifactId>-->
<!-- <version>${project.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-chroma-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-pinecone-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-hugging-face-deployment</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
4 changes: 3 additions & 1 deletion docs/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ quarkus.langchain4j.redis.dimension=180
quarkus.langchain4j.pinecone.environment=abc
quarkus.langchain4j.pinecone.index-name=abc
quarkus.langchain4j.pinecone.project-id=abc
quarkus.langchain4j.pinecone.api-key=abc
quarkus.langchain4j.pinecone.api-key=abc
quarkus.langchain4j.chat-model.provider=openai
quarkus.langchain4j.embedding-model.provider=openai

0 comments on commit cd5aae7

Please sign in to comment.