Dev Local Vector Store Plugin
Dev Local Vector Store
Section titled “Dev Local Vector Store”The Dev Local Vector Store plugin provides a local, file-based vector store for development and testing purposes. It is not intended for production use.
Installation
Section titled “Installation”pip3 install genkit-plugin-dev-local-vectorstore
Configuration
Section titled “Configuration”To use this plugin, specify it when you initialize Genkit:
from genkit.ai import Genkitfrom genkit.plugins.dev_local_vectorstore import DevLocalVectorStorefrom genkit.plugins.google_genai import VertexAI # Assuming VertexAI is used for embedder
ai = Genkit( plugins=[ VertexAI(), # Ensure the embedder's plugin is loaded DevLocalVectorStore( name='my_vectorstore', embedder='vertexai/text-embedding-004', # Example embedder ), ], # Define a default model if needed # model='vertexai/gemini-1.5-flash',)
Configuration Options
Section titled “Configuration Options”- name (str): A unique name for this vector store instance. This is used as the
retriever
argument toai.retrieve
. - embedder (str): The name of the embedding model to use. Must match a configured embedder in your Genkit project.
- embedder_options (dict, optional): Options to pass to the embedder.
Indexing Documents
Section titled “Indexing Documents”The Dev Local Vector Store automatically creates indexes. To populate with data you must call the static method .index(name, documents)
:
from genkit.ai import Genkitfrom genkit.plugins.dev_local_vectorstore import DevLocalVectorStorefrom genkit.plugins.google_genai import VertexAI # Assuming VertexAI is used for embedderfrom genkit.types import Document
# Assuming 'ai' is configured as shown in the Configuration section# ai = Genkit(...)
data_list = [ 'This is the first document.', 'This is the second document.', 'This is the third document.', "This is the fourth document.",]
genkit_docs = [Document.from_text(text=item) for item in data_list]# Ensure the vector store name matches the one in the Genkit configawait DevLocalVectorStore.index('my_vectorstore', genkit_docs)
Retrieving Documents
Section titled “Retrieving Documents”Use ai.retrieve
and pass the store name configured in the DevLocalVectorStore constructor.
from genkit.types import Document# Assuming 'ai' is configured as shown in the Configuration section# ai = Genkit(...)
docs = await ai.retrieve( query=Document.from_text('search query'), retriever='my_vectorstore', # Matches the 'name' in DevLocalVectorStore config)# print(docs) # Process the retrieved documents