Class LocalVecDocStore
java.lang.Object
com.google.genkit.plugins.localvec.LocalVecDocStore
Local file-based document store implementation.
Stores documents and their embeddings in a JSON file for simple similarity search. Uses cosine similarity for retrieval.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all documents from the store.Creates an indexer action for this document store.Creates a retriever action for this document store.voidindex(ActionContext ctx, List<Document> documents) Indexes documents with their embeddings.retrieve(ActionContext ctx, RetrieverRequest request) Retrieves documents similar to the query.intsize()Gets the number of documents in the store.
-
Constructor Details
-
LocalVecDocStore
Creates a new LocalVecDocStore.- Parameters:
config- the configuration
-
-
Method Details
-
index
Indexes documents with their embeddings.- Parameters:
ctx- the action contextdocuments- the documents to index- Throws:
GenkitException- if indexing fails
-
retrieve
public RetrieverResponse retrieve(ActionContext ctx, RetrieverRequest request) throws GenkitException Retrieves documents similar to the query.- Parameters:
ctx- the action contextrequest- the retriever request- Returns:
- the retriever response with matched documents
- Throws:
GenkitException- if retrieval fails
-
createRetriever
Creates a retriever action for this document store.- Returns:
- the retriever
-
createIndexer
Creates an indexer action for this document store.- Returns:
- the indexer
-
size
public int size()Gets the number of documents in the store.- Returns:
- the document count
-
clear
public void clear()Clears all documents from the store.
-