Class WeaviateVectorStore

java.lang.Object
com.google.genkit.plugins.weaviate.WeaviateVectorStore

public class WeaviateVectorStore extends Object
Weaviate vector store implementation for RAG workflows.

Provides vector similarity search using Weaviate's native vector search capabilities. Supports COSINE, L2_SQUARED, and DOT distance measures.

Example usage:


 // Retrieve documents
 RetrieverResponse response = genkit.retrieve("weaviate/my-collection", Document.fromText("What is AI?"),
 		Map.of("limit", 5));

 // Index documents
 genkit.index("weaviate/my-collection", List.of(Document.fromText("AI is artificial intelligence")));
 
  • Constructor Details

    • WeaviateVectorStore

      public WeaviateVectorStore(io.weaviate.client.WeaviateClient client, WeaviateCollectionConfig config, Embedder embedder)
      Creates a new WeaviateVectorStore.
      Parameters:
      client - the Weaviate client
      config - the collection configuration
      embedder - the embedder to use
  • Method Details

    • ensureCollectionExists

      public void ensureCollectionExists() throws GenkitException
      Ensures the Weaviate collection (class) exists, creating it if configured to do so.
      Throws:
      GenkitException - if collection creation fails
    • createRetriever

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

      public Indexer createIndexer()
      Creates an Indexer action for this vector store.
      Returns:
      the Indexer action
    • retrieve

      public RetrieverResponse retrieve(ActionContext ctx, RetrieverRequest request) throws GenkitException
      Retrieves documents from Weaviate using vector similarity search.
      Parameters:
      ctx - the action context
      request - the retriever request
      Returns:
      the retriever response with matched documents
      Throws:
      GenkitException - if retrieval fails
    • index

      public IndexerResponse index(ActionContext ctx, IndexerRequest request) throws GenkitException
      Indexes documents into Weaviate with their embeddings.
      Parameters:
      ctx - the action context
      request - the indexer request
      Returns:
      the indexer response
      Throws:
      GenkitException - if indexing fails