# Adding Context and Resources

### How Context Works in Qolaba

When you attach a file or a Knowledge Base to a chat, Qolaba processes and indexes that content using **Retrieval-Augmented Generation (RAG)** — a technique that allows the AI to retrieve relevant sections from your documents and use them as grounded context before generating a response.

This means the model isn't guessing or relying solely on training data. It is actively reading your material and anchoring its responses to what you've provided.

Once a file is uploaded to a chat, the AI retains context of it **throughout the entire session** — you don't need to keep the file selected or re-attach it with every prompt. Your uploaded files are also logged against the chat, so when you return to a previous conversation, you can always see which documents were used.

This is particularly valuable when:

* Working with proprietary information the model was never trained on
* Asking domain-specific questions that require your internal documents
* Maintaining consistency across tasks that rely on the same reference material
* Reducing the need to manually re-explain context in every prompt

***

### Two Ways to Add Context

1. [**Uploading Files**](/chatbot/adding-context-and-resources/uploading-files.md) — Attach files directly to a conversation for immediate, session-specific context. Best for one-off tasks where you need the AI to reference a specific document in that chat.
2. [**Knowledge Bases**](/chatbot/adding-context-and-resources/knowledge-bases.md) — Build persistent, reusable collections of documents powered by an upgraded RAG system for more accurate document retrieval and deeper context understanding. Best for recurring workflows where the same material is referenced repeatedly across chats, agents, or team members.

***

#### Which One Should You Use?

|                              | File Upload                      | Knowledge Base                           |
| ---------------------------- | -------------------------------- | ---------------------------------------- |
| **Best for**                 | One-off context, quick reference | Recurring workflows, team-shared context |
| **Persists across chats?**   | No — session only                | Yes — reusable across any chat           |
| **Supports multiple files?** | Yes                              | Yes                                      |
| **Shareable with team?**     | No                               | Yes                                      |
| **RAG-powered retrieval?**   | Yes                              | Yes — upgraded, more accurate            |

***

### Best Practices

* **One context per task** — Attach only what is relevant to the current prompt. Overloading the AI with unrelated documents reduces retrieval accuracy and response quality.
* **Name your files clearly** — The AI uses file names as part of its context. `brand-guidelines-2026.pdf` is more useful than `document1.pdf`.
* **Use Knowledge Bases for anything recurring** — If you are uploading the same file across multiple chats, it belongs in a Knowledge Base.
* **Trim large files before uploading** — Remove irrelevant pages or sections before uploading. Smaller, focused files improve retrieval precision and consume fewer credits.
* **Combine both methods when needed** — You can attach a Knowledge Base for persistent background context and upload a session-specific file for the task at hand. Both will be referenced together.
* **Review context before sending** — For complex tasks, confirm the right files or Knowledge Base are attached before running a prompt to avoid wasted credits.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.qolaba.ai/chatbot/adding-context-and-resources.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
