This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Vector Stores

Integrations for vector stores

Dapr Agents includes built-in vector store implementations for use with ConversationVectorMemory and RAG pipelines. Each store is available from dapr_agents.storage.vectorstores.

Vector stores share the same interface and are interchangeable as the vector_store argument to ConversationVectorMemory:

from dapr_agents.storage.vectorstores import ChromaVectorStore  # Replace with your vector store
from dapr_agents.document.embedder.openai import OpenAIEmbedder  # Replace with your embedding model
from dapr_agents.memory import ConversationVectorMemory

store = ChromaVectorStore(
    collection_name="my_collection",
    embedding_function=OpenAIEmbedder(),
)
memory = ConversationVectorMemory(
    vector_store=store,
    distance_metric="cosine",
)

To keep the core installation minimal, vector store dependencies must be installed separately.

1 - Chroma

Perform similarity searches with in-memory or persistent Chroma storage

Uses ChromaDB for in-memory or persistent vector search.

Installation

pip install chromadb
uv add chromadb

Usage

from dapr_agents.storage.vectorstores import ChromaVectorStore
from dapr_agents.document.embedder.openai import OpenAIEmbedder  # Replace with your embedding model

store = ChromaVectorStore(
    collection_name="my_collection",
    embedding_function=OpenAIEmbedder(),
)

2 - Postgres

Perform similarity searches with persistent Postgres storage

Uses Postgres with pgvector for production-grade vector similarity search.

Installation

pip install "psycopg[binary,pool]" pgvector
uv add 'psycopg[binary,pool]' pgvector

Usage

from dapr_agents.storage.vectorstores import PostgresVectorStore
from dapr_agents.document.embedder.openai import OpenAIEmbedder  # Replace with your embedding model

store = PostgresVectorStore(
    connection_string="postgresql://user:pass@localhost:5432/mydb",
    embedding_function=OpenAIEmbedder(),
    embedding_dimensions=1536,
)

3 - Redis

Perform similarity searches with in-memory or persistent Redis storage

Uses Redis Stack via the redisvl library for vector similarity search.

Installation

pip install redisvl
uv add redisvl

Usage

from dapr_agents.storage.vectorstores import RedisVectorStore
from dapr_agents.document.embedder.openai import OpenAIEmbedder  # Replace with your embedding model

store = RedisVectorStore(
    url="redis://localhost:6379",
    index_name="my_agent",
    embedding_function=OpenAIEmbedder(),
    embedding_dimensions=1536,
    distance_metric="cosine",  # "cosine", "l2", or "ip"
    storage_type="hash",       # "hash" or "json"
)