What it is
A vector store is where you persist embedding vectors so you can query them later with nearest-neighbor similarity search. In a RAG system, it’s the component that lets you retrieve relevant chunks or memories for a new question.
In Phero, vector stores are typically used through the rag package: you ingest chunks (embed + store), then query by embedding the user’s question.
How it fits in the stack
- textsplitter breaks documents into chunks
- embedding converts chunks/queries into vectors
- vectorstore persists vectors and supports similarity search
- rag ties it together and exposes retrieval to agents
Example: Qdrant-backed store (document RAG)
The examples/rag-chatbot program uses Qdrant. The important parts are:
- Infer the vector size from your embedder
- Create a Qdrant client
- Create a vector store bound to a collection
- Pass the store into
rag.New(...)
// From examples/rag-chatbot (edited for brevity)
// Infer vector size from the embedder output
vecs, err := embedder.Embed(ctx, []string{chunks[0]})
if err != nil {
// handle error
}
vectorSize := uint64(len(vecs[0]))
// Qdrant client
qc, err := qdrantapi.NewClient(&qdrantapi.Config{
Host: qdrantHost,
Port: qdrantPort,
APIKey: strings.TrimSpace(qdrantAPIKey),
UseTLS: qdrantUseTLS,
})
if err != nil {
// handle error
}
// Vector store bound to a single collection
store, err := vsqdrant.New(
qc,
strings.TrimSpace(qdrantCollection),
vsqdrant.WithVectorSize(vectorSize),
vsqdrant.WithWait(true),
)
if err != nil {
// handle error
}
// Use the store via RAG
ragEngine, _ := rag.New(store, embedder, rag.WithTopK(topK))
The RAG engine handles ingestion and retrieval; the vector store’s job is to provide durable storage and fast similarity search.
Example: Qdrant-backed store (semantic memory)
The examples/long-term-memory program uses the same Qdrant store, but wraps the RAG engine as semantic memory.
// From examples/long-term-memory (edited for brevity)
store, err := vsqdrant.New(
qc,
qdrantCollection,
vsqdrant.WithVectorSize(vectorSize),
vsqdrant.WithWait(true),
)
if err != nil {
// handle error
}
// Ensure the collection exists
_ = store.EnsureCollection(ctx)
ragEngine, _ := rag.New(store, embedder, rag.WithTopK(topK))
conversationMemory := ragmemory.New(ragEngine)
a.SetMemory(conversationMemory)
Run the examples
The Qdrant-based examples require a running Qdrant instance. Provider setup depends on your chosen LLM/embedder; follow each example README.
# Start Qdrant (one quick way)
docker run --rm -p 6333:6333 -p 6334:6334 qdrant/qdrant
# Document RAG over a local file
go run ./examples/rag-chatbot -file /path/to/your/file.txt
# Semantic long-term memory
go run ./examples/long-term-memory
Other backends
Phero also includes a PostgreSQL + pgvector adapter under vectorstore/psql.
Use it when you want vectors stored alongside your relational data.