Vector Store
Give your agents long-term knowledge with vector database integrations
Vector stores give agents the ability to store and retrieve knowledge from large document collections โ enabling RAG (Retrieval Augmented Generation) where agents answer questions grounded in your data.
graph LR
subgraph "Vector Store"
D[๐ Documents] --> E[๐ง Embed]
E --> VS[(๐พ Vector Store)]
Q[โ Query] --> QE[๐ง Embed]
QE --> VS
VS --> R[โ
Top Results]
R --> A[๐ค Agent]
end
classDef input fill:#6366F1,stroke:#7C90A0,color:#fff
classDef process fill:#F59E0B,stroke:#7C90A0,color:#fff
classDef store fill:#189AB4,stroke:#7C90A0,color:#fff
classDef output fill:#10B981,stroke:#7C90A0,color:#fff
class D,Q input
class E,QE process
class VS store
class R,A output
classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
classDef tool fill:#189AB4,stroke:#7C90A0,color:#fff
classDef agent fill:#8B0000,color:#fff
classDef tool fill:#189AB4,color:#fffQuick Start
- Simple Usage
typescript import { Agent } from 'praisonai'; const agent = new Agent({ name: 'Knowledge Assistant', instructions: 'Answer questions using the provided knowledge base.', knowledge: ['./docs/', './manuals/product.pdf'] }); const response = await agent.chat('What is our refund policy?'); console.log(response); - With Configuration
typescript import { Agent, createPineconeStore } from 'praisonai'; const vectorStore = createPineconeStore({ apiKey: process.env.PINECONE_API_KEY }); const agent = new Agent({ name: 'Research Assistant', instructions: 'Search the knowledge base and answer accurately.', knowledge: { vectorStore, indexName: 'company-docs' } }); await agent.chat('Find information about our pricing plans'); - In-Memory Store (Testing)
typescript import { Agent, createMemoryVectorStore } from 'praisonai'; const vectorStore = createMemoryVectorStore(); const agent = new Agent({ instructions: 'Answer questions from the knowledge base.', knowledge: { vectorStore, indexName: 'test-docs' } });
How It Works
sequenceDiagram
participant User
participant Agent
participant Embedder
participant VS as Vector Store
User->>Agent: "What is our refund policy?"
Agent->>Embedder: Embed question
Embedder-->>Agent: Query vector
Agent->>VS: Search top_k=5
VS-->>Agent: Relevant documents
Agent->>Agent: Generate answer with context
Agent-->>User: Grounded responseSupported Vector Stores
| Store | Use Case |
|---|---|
| Pinecone | Production, large-scale |
| Weaviate | Hybrid search, self-hosted |
| Qdrant | High performance, self-hosted |
| Chroma | Development, local |
| Memory | Testing, ephemeral |
Configuration Options
Vector Store API ReferenceTypeScript vector store configuration options
Common Patterns
Agent with Search Tool
import { Agent, createTool, createPineconeStore } from 'praisonai';
const vectorStore = createPineconeStore({
apiKey: process.env.PINECONE_API_KEY
});
const searchDocs = createTool({
name: 'search_docs',
description: 'Search the knowledge base for relevant information',
parameters: {
type: 'object',
properties: {
query: { type: 'string', description: 'Search query' }
},
required: ['query']
},
execute: async ({ query }) => {
const results = await vectorStore.query({
indexName: 'documents',
queryText: query,
topK: 5
});
return results.map(r => r.content).join('\n\n');
}
});
const agent = new Agent({
name: 'Research Assistant',
instructions: 'Use the search tool to find accurate information.',
tools: [searchDocs]
});Multi-Agent with Shared Knowledge
import { Agent, createPineconeStore } from 'praisonai';
const sharedStore = createPineconeStore({
apiKey: process.env.PINECONE_API_KEY
});
const researcher = new Agent({
name: 'Researcher',
instructions: 'Find relevant information from the knowledge base.',
knowledge: { vectorStore: sharedStore, indexName: 'docs' }
});
const writer = new Agent({
name: 'Writer',
instructions: 'Write clear responses based on the research.',
knowledge: { vectorStore: sharedStore, indexName: 'docs' }
});Setup Pinecone Index
import { createPineconeStore } from 'praisonai';
const pinecone = createPineconeStore({
apiKey: process.env.PINECONE_API_KEY
});
await pinecone.createIndex({
indexName: 'agent-knowledge',
dimension: 1536,
metric: 'cosine'
});Best Practices
Use memory store for development
createMemoryVectorStore() requires no external dependencies. Switch to Pinecone or Qdrant before going to production.
Chunk large documents
Split large documents into 500โ1000 token chunks before indexing. Smaller chunks retrieve more precisely.
Set top_k carefully
A top_k of 3โ5 gives the agent focused context. Higher values can dilute relevance.
Keep embeddings consistent
Use the same embedding model for indexing and querying. Mixing models produces incorrect similarity scores.