Class LocalVecDocStore

java.lang.Object
com.google.genkit.plugins.localvec.LocalVecDocStore

public class LocalVecDocStore extends Object
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 Details

    • LocalVecDocStore

      public LocalVecDocStore(LocalVecConfig config)
      Creates a new LocalVecDocStore.
      Parameters:
      config - the configuration
  • Method Details

    • index

      public void index(ActionContext ctx, List<Document> documents) throws GenkitException
      Indexes documents with their embeddings.
      Parameters:
      ctx - the action context
      documents - 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 context
      request - the retriever request
      Returns:
      the retriever response with matched documents
      Throws:
      GenkitException - if retrieval fails
    • createRetriever

      public Retriever createRetriever()
      Creates a retriever action for this document store.
      Returns:
      the retriever
    • createIndexer

      public Indexer 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.