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

# Knowledge • Rust AI Agent SDK

> Knowledge: Main knowledge manager.

# Knowledge

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

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

Main knowledge manager.

## Fields

| Name        | Type                  | Description      |
| ----------- | --------------------- | ---------------- |
| `config`    | `KnowledgeConfig`     | Configuration    |
| `documents` | `Vec&lt;Document&gt;` | Documents        |
| `chunking`  | `Chunking`            | Chunking utility |

## Methods

### `new`

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

Create a new knowledge builder

### `add`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn add(&mut self, content: &str, metadata: Option<HashMap<String, String>>) -> Result<AddResult>
```

Add content to knowledge base

**Parameters:**

| Name       | Type                          |
| ---------- | ----------------------------- |
| `content`  | `&str`                        |
| `metadata` | `Option&lt;HashMap&lt;String` |

### `add_document`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn add_document(&mut self, document: Document) -> Result<AddResult>
```

Add a document

**Parameters:**

| Name       | Type       |
| ---------- | ---------- |
| `document` | `Document` |

### `search`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn search(&self, query: &str, limit: usize) -> Result<SearchResult>
```

Search knowledge base (placeholder - would use embeddings in real impl)

**Parameters:**

| Name    | Type    |
| ------- | ------- |
| `query` | `&str`  |
| `limit` | `usize` |

### `get`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn get(&self, id: &str) -> Option<&Document>
```

Get document by ID

**Parameters:**

| Name | Type   |
| ---- | ------ |
| `id` | `&str` |

### `delete`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn delete(&mut self, id: &str) -> bool
```

Delete document by ID

**Parameters:**

| Name | Type   |
| ---- | ------ |
| `id` | `&str` |

### `clear`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn clear(&mut self) -> ()
```

Clear all documents

### `len`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn len(&self) -> usize
```

Get document count

### `is_empty`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn is_empty(&self) -> bool
```

Check if empty

### `chunk`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn chunk(&self, text: &str) -> Vec<String>
```

Chunk text using configured strategy

**Parameters:**

| Name   | Type   |
| ------ | ------ |
| `text` | `&str` |

## Source

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

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Knowledge" icon="book" href="/docs/rust/knowledge" />

  <Card title="Rust Documents" icon="file-lines" href="/docs/rust/documents" />

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