-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
95 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...modules/ROOT/examples/io/quarkiverse/langchain4j/samples/IngestorExampleWithPinecone.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters