> ## 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 Config • Rust AI Agent SDK

> RAGConfig: Configuration for RAG pipeline.

# RAGConfig

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

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

Configuration for RAG pipeline.

## Fields

| Name                 | Type                | Description                          |
| -------------------- | ------------------- | ------------------------------------ |
| `top_k`              | `usize`             | Maximum number of chunks to retrieve |
| `score_threshold`    | `f32`               | Minimum relevance score threshold    |
| `max_context_tokens` | `usize`             | Maximum context tokens               |
| `strategy`           | `RetrievalStrategy` | Retrieval strategy                   |
| `citations_mode`     | `CitationsMode`     | Citations mode                       |
| `rerank`             | `bool`              | Enable reranking                     |
| `compress`           | `bool`              | Enable context compression           |
| `chunk_overlap`      | `usize`             | Chunk overlap for splitting          |
| `chunk_size`         | `usize`             | Chunk size for splitting             |

## Methods

### `new`

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

Create a new RAGConfig

### `top_k`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn top_k(mut self, k: usize) -> Self
```

Set top\_k

**Parameters:**

| Name | Type    |
| ---- | ------- |
| `k`  | `usize` |

### `score_threshold`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn score_threshold(mut self, threshold: f32) -> Self
```

Set score threshold

**Parameters:**

| Name        | Type  |
| ----------- | ----- |
| `threshold` | `f32` |

### `max_context_tokens`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn max_context_tokens(mut self, tokens: usize) -> Self
```

Set max context tokens

**Parameters:**

| Name     | Type    |
| -------- | ------- |
| `tokens` | `usize` |

### `strategy`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn strategy(mut self, strategy: RetrievalStrategy) -> Self
```

Set retrieval strategy

**Parameters:**

| Name       | Type                |
| ---------- | ------------------- |
| `strategy` | `RetrievalStrategy` |

### `citations_mode`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn citations_mode(mut self, mode: CitationsMode) -> Self
```

Set citations mode

**Parameters:**

| Name   | Type            |
| ------ | --------------- |
| `mode` | `CitationsMode` |

### `rerank`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn rerank(mut self, enable: bool) -> Self
```

Enable reranking

**Parameters:**

| Name     | Type   |
| -------- | ------ |
| `enable` | `bool` |

### `compress`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn compress(mut self, enable: bool) -> Self
```

Enable compression

**Parameters:**

| Name     | Type   |
| -------- | ------ |
| `enable` | `bool` |

## Source

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

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Configuration" icon="gear" href="/docs/rust/configuration" />

  <Card title="Rust Installation" icon="download" href="/docs/rust/installation" />

  <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" />
</CardGroup>
