> ## 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.

# Retrieval

> Find relevant information for agents

Agents can search and retrieve relevant information from your documents.

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

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

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

## Quick Start

**1. Simple Usage**

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

const agent = new Agent({
  instructions: 'Answer questions using the provided documents',
  knowledge: './docs/'  // Folder of documents
});

await agent.chat('What is the return policy?');
// Agent searches docs and answers accurately
```

**2. With Configuration**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
const agent = new Agent({
  knowledge: {
    path: './docs/',
    strategy: 'semantic',  // or 'keyword', 'hybrid'
    topK: 5
  }
});
```

***

## User Interaction Flow

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Knowledge
    
    User->>Agent: "What's the return policy?"
    Agent->>Knowledge: Search for relevant docs
    Knowledge-->>Agent: Matching passages
    Agent->>Agent: Generate answer
    Agent-->>User: "You can return within 30 days..."
```

***

## Configuration Levels

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
// Level 1: String - Path to documents
const agent = new Agent({
  knowledge: './docs/'
});

// Level 2: Array - Multiple sources
const agent = new Agent({
  knowledge: ['./policies/', './faq/', './guides/']
});

// Level 3: Dict - Full options
const agent = new Agent({
  knowledge: {
    path: './docs/',
    strategy: 'hybrid',
    topK: 10,
    minScore: 0.7,
    chunkSize: 500
  }
});
```

***

## Retrieval Strategies

| Strategy | Best For |
| - | - |
| `keyword` | Exact term matching |
| `semantic` | Meaning-based search |
| `hybrid` | Combines both approaches |

***

## API Reference

> [card] [KnowledgeConfig](https://praison.ai/docs/sdk/reference/typescript/classes/KnowledgeConfig.md)
>
> Complete configuration options

> [card] [RAG](https://praison.ai/docs/sdk/reference/typescript/classes/RAG.md)
>
> RAG class documentation

***

## Best Practices

> [accordion] Use semantic for complex questions
>
> Semantic search finds related content even without exact keywords.

> [accordion] Keep documents focused
>
> Smaller, topic-specific documents retrieve better.

> [accordion] Set minimum score
>
> Filter out low-relevance results with minScore.

***

## Related

> [card] [Knowledge](https://praison.ai/docs/js/knowledge-base.md)
>
> Knowledge base

> [card] [RAG](https://praison.ai/docs/js/rag-agent.md)
>
> Retrieval augmented generation


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.