# Using RAG

Your Toolhouse agents can perform Retrieval Augmented Generation (RAG) using your own data. Toolhouse includes a fully managed RAG pipeline that includes storage, upload, chunking, and retrieval. Toolhouse RAG is already integrated into your agent.

Here's how Toolhouse RAG works:

* You upload files to the Toolhouse RAG.
* Toolhouse triggers the RAG pipeline. Your RAG files will be analyzed to determine the chunking strategy.
* You assign a RAG folder to one or more agents.
* When you call the agent, it will know that it has a RAG folder available and it will be automatically prompted to use your RAG folder to complement its knowledge and better inform its context.

## Basic flow

{% stepper %}
{% step %}

### Create a folder

You can create RAG **folders** using `th rag create <folder_name>`. You will need to create at least one folder in order to use RAG. Subfolders are not supported.

```bash
th rag create employee_policy_documents
```

{% endstep %}

{% step %}

### **Upload files**

Use `th rag add` to upload one or more files into a folder.

```bash
th rag add employee_policy_documents *.pdf
```

{% endstep %}

{% step %}

### **Reference the folder in the agent file**

You will need to update your th file with `rag: <folder_name>`. This will tell your agent to perform RAG on that folder.

```yaml
id: 69ba3e7e-xxxx-xxxx-xxxx-dc8cb0f86c7b

title: HR Employee Handbook

prompt: |
  Look into the internal company knowledge to answer this question: 
  {question}.
  
public: false
rag: employee_policy_documents

```

{% endstep %}

{% step %}

### Run and deploy

Test out your agent's behavior by using `th run` . When you are satisfied with the results, run `th deploy` to enable RAG on your agent.

Every time the agent is called, the agent will decide to perform one or more RAG queries to retrieve data from your RAG folder.
{% endstep %}
{% endstepper %}

## Supported File Types

Toolhouse RAG supports most text-based files and PDFs. The size limit is 10 MB for each file you upload.

| Extension | MIME Type       |
| --------- | --------------- |
| .pdf      | application/pdf |
| .txt      | text/plain      |
| .text     | text/plain      |
| .log      | text/plain      |
| .ini      | text/plain      |
| .conf     | text/plain      |
| .csv      | text/plain      |
| .asc      | text/plain      |
| .lst      | text/plain      |
| .md       | text/plain      |
| .sh       | text/plain      |
| .py       | text/plain      |
| .js       | text/plain      |
| .css      | text/plain      |
| .html     | text/plain      |
| .htm      | text/plain      |
| .xml      | text/plain      |
| .json     | text/plain      |
| .yaml     | text/plain      |
| .yml      | text/plain      |
