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

# RAG • Rust AI Agent SDK

> RAG: Main RAG pipeline.

# RAG

> Defined in the [**RAG**](../modules/rag) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

Main RAG pipeline.

## Fields

| Name      | Type                | Description              |
| --------- | ------------------- | ------------------------ |
| `config`  | `RAGConfig`         | Configuration            |
| `model`   | `String`            | LLM model for generation |
| `sources` | `Vec&lt;String&gt;` | Knowledge sources        |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new() -> RAGBuilder
```

Create a new RAG builder

### `query`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn query(&self, question: &str) -> Result<RAGResult>
```

Query the RAG pipeline (placeholder)

**Parameters:**

| Name       | Type   |
| ---------- | ------ |
| `question` | `&str` |

### `add_source`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn add_source(&mut self, source: impl Into<String>) -> ()
```

Add a knowledge source

**Parameters:**

| Name     | Type                      |
| -------- | ------------------------- |
| `source` | `impl Into&lt;String&gt;` |

### `build_context`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn build_context(&self, chunks: &[ContextChunk]) -> String
```

Build context from chunks

**Parameters:**

| Name     | Type              |
| -------- | ----------------- |
| `chunks` | `&[ContextChunk]` |

### `truncate_context`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn truncate_context(&self, context: &str, max_tokens: usize) -> String
```

Truncate context to fit token budget

**Parameters:**

| Name         | Type    |
| ------------ | ------- |
| `context`    | `&str`  |
| `max_tokens` | `usize` |

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/rag/mod.rs#L467">
  `praisonai/src/rag/mod.rs` at line 467
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust RAG" icon="magnifying-glass" href="/docs/rust/rag" />

  <Card title="Rust Retrieval" icon="search" href="/docs/rust/retrieval" />

  <Card title="Rust Vector Store" icon="database" href="/docs/rust/vector-store" />

  <Card title="Rust Chunking" icon="scissors" href="/docs/rust/chunking" />
</CardGroup>
