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

# Knowledge CLI

> CLI commands for knowledge base management

# Knowledge CLI Commands

The `praisonai knowledge` command group provides CLI access to knowledge base management.

## Commands Overview

| Command  | Description                               |
| -------- | ----------------------------------------- |
| `index`  | Add/index documents into a knowledge base |
| `search` | Search/retrieve from knowledge base       |
| `add`    | Alias for `index`                         |
| `list`   | List available knowledge bases            |

## Index Command

Add documents to a knowledge base.

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai knowledge index [OPTIONS] SOURCES...
```

### Arguments

| Argument  | Description                                            |
| --------- | ------------------------------------------------------ |
| `SOURCES` | Source files, directories, or URLs to index (required) |

### Options

| Option          | Short | Description                               | Default   |
| --------------- | ----- | ----------------------------------------- | --------- |
| `--collection`  | `-c`  | Collection/knowledge base name            | `default` |
| `--user-id`     | `-u`  | User ID for scoping (required for mem0)   | None      |
| `--agent-id`    | `-a`  | Agent ID for scoping                      | None      |
| `--run-id`      | `-r`  | Run ID for scoping                        | None      |
| `--backend`     | `-b`  | Knowledge backend: mem0, chroma, internal | `mem0`    |
| `--config`      | `-f`  | Config file path                          | None      |
| `--verbose`     | `-v`  | Verbose output                            | False     |
| `--profile`     |       | Enable performance profiling              | False     |
| `--profile-out` |       | Save profile to JSON file                 | None      |

### Examples

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Index a directory with user scope
praisonai knowledge index ./docs --user-id myuser

# Index with specific collection and agent scope
praisonai knowledge index paper.pdf --collection research --agent-id research_agent

# Index using chroma backend
praisonai knowledge index ./data --backend chroma

# Index with profiling
praisonai knowledge index ./docs --user-id myuser --profile --profile-out ./profile.json
```

## Search Command

Search/retrieve from a knowledge base without LLM generation.

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai knowledge search [OPTIONS] QUERY
```

### Arguments

| Argument | Description             |
| -------- | ----------------------- |
| `QUERY`  | Search query (required) |

### Options

| Option         | Short | Description                               | Default   |
| -------------- | ----- | ----------------------------------------- | --------- |
| `--collection` | `-c`  | Collection to search                      | `default` |
| `--user-id`    | `-u`  | User ID for scoping (required for mem0)   | None      |
| `--agent-id`   | `-a`  | Agent ID for scoping                      | None      |
| `--run-id`     | `-r`  | Run ID for scoping                        | None      |
| `--backend`    | `-b`  | Knowledge backend: mem0, chroma, internal | `mem0`    |
| `--top-k`      | `-k`  | Number of results to retrieve             | `5`       |
| `--hybrid`     |       | Use hybrid retrieval (dense + BM25)       | False     |
| `--config`     | `-f`  | Config file path                          | None      |
| `--verbose`    | `-v`  | Verbose output                            | False     |
| `--profile`    |       | Enable performance profiling              | False     |

### Examples

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Basic search with user scope
praisonai knowledge search "capital of France" --user-id myuser

# Search specific collection with more results
praisonai knowledge search "main findings" --collection research --top-k 10

# Hybrid search using chroma backend
praisonai knowledge search "Python tutorial" --hybrid --backend chroma

# Search with agent scope
praisonai knowledge search "company policy" --agent-id company_bot
```

## List Command

List available knowledge bases/collections.

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai knowledge list [OPTIONS]
```

### Options

| Option      | Short | Description    | Default |
| ----------- | ----- | -------------- | ------- |
| `--verbose` | `-v`  | Verbose output | False   |

### Example

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai knowledge list
```

Output:

```
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Collection   ┃ Path                              ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ default      │ ./.praison/knowledge/default      │
│ research     │ ./.praison/knowledge/research     │
└──────────────┴───────────────────────────────────┘
```

## Scope Identifiers

<Warning>
  The **mem0 backend requires at least one scope identifier** (`--user-id`, `--agent-id`, or `--run-id`). If none is provided, a warning will be shown and `default_user` will be used.
</Warning>

### When to Use Each Scope

| Scope        | Use Case                     | Example              |
| ------------ | ---------------------------- | -------------------- |
| `--user-id`  | Per-user knowledge isolation | Multi-tenant apps    |
| `--agent-id` | Shared agent knowledge       | Company FAQ bot      |
| `--run-id`   | Session-specific context     | Conversation history |

## Backend Selection

### mem0 (Default)

Best for production apps with multi-user support:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai knowledge index ./docs --user-id alice --backend mem0
```

### Chroma

Best for local development:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai knowledge index ./docs --backend chroma
```

### Internal

Lightweight built-in storage:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai knowledge index ./docs --backend internal
```

## Configuration File

You can provide a YAML configuration file:

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# knowledge-config.yaml
knowledge:
  vector_store:
    provider: chroma
    config:
      collection_name: my_docs
      path: ./.praison/knowledge/my_docs
  retrieval:
    strategy: hybrid
```

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai knowledge index ./docs --config knowledge-config.yaml
```

## Profiling

Enable profiling to measure performance:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai knowledge index ./docs --user-id myuser --profile --profile-out ./profile.json
```

The profile output includes:

* Wall time
* Peak memory usage
* Modules imported
* Top functions by time

## Related Commands

* `praisonai rag query` - Answer questions with citations
* `praisonai chat` - Interactive chat with knowledge retrieval
