> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Vector Stores

> Give your Agents long-term memory with vector database integrations

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    User([User]) --> Agent[Agent]
    Agent --> Output([Output])

    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef tool fill:#189AB4,stroke:#7C90A0,color:#fff

    class Agent agent
    class User,Output tool
    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff
```

# Vector Stores for Agents

Vector stores give your Agents the ability to store and retrieve knowledge from large document collections. This enables RAG (Retrieval Augmented Generation) where Agents can answer questions based on your custom data.

## Quick Start

<Steps>
  <Step title="Simple Usage">
    ```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    import { Agent, createPineconeStore } from 'praisonai';

    // Create vector store for Agent's knowledge
    const vectorStore = createPineconeStore({
      apiKey: process.env.PINECONE_API_KEY!
    });

    // Create Agent with vector store knowledge
    const agent = new Agent({
      name: 'Knowledge Assistant',
      instructions: 'You answer questions using the provided knowledge base.',
      knowledge: {
        vectorStore,
        indexName: 'company-docs'
      }
    });

    // Agent automatically retrieves relevant context
    const response = await agent.chat('What is our refund policy?');
    ```
  </Step>

  <Step title="With Configuration">
    See the sections below for advanced options.
  </Step>
</Steps>

***

## Agent with Vector Store Knowledge

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent, createPineconeStore } from 'praisonai';

// Create vector store for Agent's knowledge
const vectorStore = createPineconeStore({
  apiKey: process.env.PINECONE_API_KEY!
});

// Create Agent with vector store knowledge
const agent = new Agent({
  name: 'Knowledge Assistant',
  instructions: 'You answer questions using the provided knowledge base.',
  knowledge: {
    vectorStore,
    indexName: 'company-docs'
  }
});

// Agent automatically retrieves relevant context
const response = await agent.chat('What is our refund policy?');
```

## Supported Vector Stores

| Store        | Description              | Best For             |
| ------------ | ------------------------ | -------------------- |
| **Pinecone** | Managed vector database  | Production Agents    |
| **Weaviate** | Open-source with GraphQL | Hybrid search Agents |
| **Qdrant**   | High-performance         | Self-hosted Agents   |
| **Chroma**   | Lightweight, embedded    | Development/Testing  |
| **Memory**   | In-memory                | Unit testing Agents  |

## Agent with RAG Tool

Create a tool that lets your Agent search the vector store:

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent, createTool, createPineconeStore } from 'praisonai';

const vectorStore = createPineconeStore({
  apiKey: process.env.PINECONE_API_KEY!
});

// Create search tool for the Agent
const searchKnowledge = createTool({
  name: 'search_knowledge',
  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',
      vector: await getEmbedding(query),
      topK: 5,
      includeMetadata: true
    });
    return results.map(r => r.content).join('\n\n');
  }
});

// Agent with knowledge search capability
const agent = new Agent({
  name: 'Research Assistant',
  instructions: 'Search the knowledge base to answer user questions accurately.',
  tools: [searchKnowledge]
});

const response = await agent.chat('Find information about our pricing plans');
```

## Multi-Agent with Shared Knowledge

Multiple Agents can share the same vector store:

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent, Agents, createPineconeStore } from 'praisonai';

const sharedKnowledge = createPineconeStore({
  apiKey: process.env.PINECONE_API_KEY!
});

// Research Agent - retrieves information
const researcher = new Agent({
  name: 'Researcher',
  instructions: 'Find relevant information from the knowledge base.',
  knowledge: { vectorStore: sharedKnowledge, indexName: 'docs' }
});

// Writer Agent - uses retrieved information
const writer = new Agent({
  name: 'Writer',
  instructions: 'Write clear responses based on the research provided.',
  knowledge: { vectorStore: sharedKnowledge, indexName: 'docs' }
});

const agents = new AgentTeam({
  agents: [researcher, writer],
  tasks: [
    { agent: researcher, description: 'Research: {query}' },
    { agent: writer, description: 'Write a response based on the research' }
  ]
});

await agents.start({ query: 'What are our product features?' });
```

## Agent that Builds Knowledge

An Agent can add documents to the vector store:

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent, createTool, createPineconeStore } from 'praisonai';

const vectorStore = createPineconeStore({
  apiKey: process.env.PINECONE_API_KEY!
});

const addToKnowledge = createTool({
  name: 'add_to_knowledge',
  description: 'Add new information to the knowledge base',
  parameters: {
    type: 'object',
    properties: {
      content: { type: 'string', description: 'Content to store' },
      source: { type: 'string', description: 'Source of the information' }
    },
    required: ['content', 'source']
  },
  execute: async ({ content, source }) => {
    const embedding = await getEmbedding(content);
    await vectorStore.upsert({
      indexName: 'documents',
      vectors: [{
        id: `doc-${Date.now()}`,
        vector: embedding,
        content,
        metadata: { source, addedAt: new Date().toISOString() }
      }]
    });
    return `Added to knowledge base from ${source}`;
  }
});

const learningAgent = new Agent({
  name: 'Learning Agent',
  instructions: 'Learn new information and store it in the knowledge base.',
  tools: [addToKnowledge]
});
```

## Vector Store Setup

### Pinecone

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { createPineconeStore } from 'praisonai';

const pinecone = createPineconeStore({
  apiKey: process.env.PINECONE_API_KEY!
});

// Initialize index for Agent
await pinecone.createIndex({
  indexName: 'agent-knowledge',
  dimension: 1536,
  metric: 'cosine'
});
```

### Weaviate

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { createWeaviateStore } from 'praisonai';

const weaviate = createWeaviateStore({
  host: 'your-cluster.weaviate.network',
  apiKey: process.env.WEAVIATE_API_KEY
});
```

### Qdrant

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { createQdrantStore } from 'praisonai';

const qdrant = createQdrantStore({
  url: 'http://localhost:6333',
  apiKey: process.env.QDRANT_API_KEY
});
```

### Memory (Testing)

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { createMemoryVectorStore } from 'praisonai';

// Perfect for testing Agents without external dependencies
const memory = createMemoryVectorStore();
```

## Environment Variables

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
PINECONE_API_KEY=your-pinecone-key
WEAVIATE_API_KEY=your-weaviate-key
QDRANT_API_KEY=your-qdrant-key
OPENAI_API_KEY=your-openai-key  # For embeddings
```

## Related

<CardGroup cols={2}>
  <Card title="Knowledge Base" icon="book" href="/docs/js/knowledge-base">Knowledge Base</Card>
  <Card title="Graph RAG" icon="robot" href="/docs/js/graph-rag">Graph RAG</Card>
</CardGroup>
