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

# Knowledge Base

> Add documents, URLs, Q&A pairs, and text snippets to give your agent accurate, grounded responses.

The Knowledge Base is the foundation of your agent's knowledge. By adding approved source material — documents, websites, curated Q\&A pairs, and text snippets — you give your agent the content it needs to provide accurate, evidence-based responses grounded in your own materials rather than general AI knowledge.

<Info>
  Access the Knowledge Base by selecting an agent from the **Agents** list and clicking the **Knowledge Base** tab.
</Info>

## How it works

When a user asks a question, the RoseRx Platform retrieves relevant information from your Knowledge Base in two stages:

1. **Q\&A pair lookup** — The platform first checks whether the question matches one of your curated Q\&A pairs. If a confident match is found, the exact pre-approved answer is returned to the user.
2. **Document retrieval (fallback)** — If no Q\&A match is found, the platform runs a **hybrid search** — combining semantic similarity with keyword matching — across your PDFs, URLs, and text snippets. The most relevant chunks are passed to the AI model as context, and the model generates a grounded response (**Retrieval-Augmented Generation**, or RAG).

This two-stage approach means you can lock down high-stakes answers with Q\&A pairs while still letting the agent draw on broader source material for everything else.

## Source types

You can add four types of source material to your Knowledge Base. Each is suited to different content and behaves differently at runtime.

<CardGroup cols={2}>
  <Card title="PDF documents" icon="file-pdf">
    Upload PDFs such as prescribing information, clinical study reports, product information leaflets, and approved marketing materials.
  </Card>

  <Card title="Website URLs" icon="globe">
    Add web page URLs to scrape and index content from your existing websites, product pages, or online resources.
  </Card>

  <Card title="Q&A pairs" icon="comments-question">
    Define a question and an exact, pre-approved answer. When a user's question matches semantically, the answer is returned verbatim.
  </Card>

  <Card title="Text snippets" icon="align-left">
    Paste free-form text — paragraphs of product information, policy excerpts, or supporting context — for the agent to reference.
  </Card>
</CardGroup>

### At a glance

|                        | PDF documents                                           | Website URLs                                            | Q\&A pairs                                          | Text snippets                                               |
| ---------------------- | ------------------------------------------------------- | ------------------------------------------------------- | --------------------------------------------------- | ----------------------------------------------------------- |
| **Best for**           | Long, authoritative source material (PI, CSR, leaflets) | Existing public web content you don't want to duplicate | Canonical, pre-approved answers to common questions | Free-form context that doesn't fit a single question/answer |
| **Format**             | PDF file (≤ 10 MB)                                      | Public URL                                              | Question + answer                                   | Plain text (≥ 100 characters)                               |
| **How it's used**      | Chunked, embedded, retrieved as context                 | Scraped, chunked, embedded, retrieved as context        | Returned verbatim when the question matches         | Chunked, embedded, retrieved as context                     |
| **Processing**         | Asynchronous indexing                                   | Asynchronous indexing                                   | Available immediately                               | Asynchronous indexing                                       |
| **Retrieval priority** | Fallback after Q\&A lookup                              | Fallback after Q\&A lookup                              | Checked first                                       | Fallback after Q\&A lookup                                  |

## Uploading PDF documents

<Steps>
  <Step title="Open the upload sheet">
    On the Knowledge Base tab, click **Add Document**. An upload sheet will appear.
  </Step>

  <Step title="Select your file">
    Click the upload area or drag and drop a PDF file. The file must be in **PDF format** and no larger than **10 MB**.
  </Step>

  <Step title="Add metadata">
    Fill in the document details:

    * **Name** — A descriptive name for the document
    * **Author** — The document author or organization
    * **Publication date** — When the document was published
    * **Therapeutic area** — The relevant therapy area
    * **Source type** — The category of the document
  </Step>

  <Step title="Upload and process">
    Click **Upload** to submit the document. It will begin processing immediately.
  </Step>
</Steps>

<Tip>
  Upload your product information leaflets, clinical studies, SmPCs, and approved labeling to give your agent comprehensive, authoritative knowledge.
</Tip>

## Adding website URLs

<Steps>
  <Step title="Open the URL sheet">
    On the Knowledge Base tab, click **Add URL**. A URL entry sheet will appear.
  </Step>

  <Step title="Enter the URL">
    Paste the full website URL you want to index. The page content will be scraped and processed.
  </Step>

  <Step title="Add metadata">
    Fill in the source details — name, author, publication date, therapeutic area, and source type — just as you would for a PDF.
  </Step>

  <Step title="Submit for processing">
    Click **Add** to submit the URL. The platform will fetch and index the page content.
  </Step>
</Steps>

## Adding Q\&A pairs

A Q\&A pair is a curated question with an exact, pre-approved answer. When a user asks a question that semantically matches yours, the platform returns your answer verbatim — no model paraphrasing.

<Steps>
  <Step title="Open the Q&A pair sheet">
    On the Knowledge Base tab, click **Add Q\&A Pair**. A creation sheet will appear.
  </Step>

  <Step title="Write the question">
    Enter the question the way a user would naturally ask it. The question is what the platform matches against — phrasing matters.
  </Step>

  <Step title="Write the answer">
    Enter the exact answer you want returned. This text is shown to the user as-is, so use the wording you would approve for any other communication.
  </Step>

  <Step title="Save">
    Click **Save**. The Q\&A pair is available immediately — no asynchronous indexing.
  </Step>
</Steps>

<Note>
  Only the **question** is embedded for semantic matching. If users phrase the same question in significantly different ways, consider adding multiple Q\&A pairs covering each phrasing.
</Note>

<Tip>
  Q\&A pairs are ideal when wording matters — regulatory disclaimers, brand-approved phrasing, scripted responses to sensitive questions, and FAQs where you don't want the model to improvise.
</Tip>

## Adding text snippets

Text snippets are free-form passages of text — a paragraph from a leaflet, a policy excerpt, a section of product information — that the agent can reference when answering questions.

<Steps>
  <Step title="Open the text snippet sheet">
    On the Knowledge Base tab, click **Add Text Snippet**. A creation sheet will appear.
  </Step>

  <Step title="Name the snippet">
    Give the snippet a descriptive name so you can find and manage it later.
  </Step>

  <Step title="Paste the content">
    Paste the text you want to add. Snippets must be **at least 100 characters**.
  </Step>

  <Step title="Add optional metadata">
    Set a **source** (where the content came from) and a **category** if you want to organize your snippets.
  </Step>

  <Step title="Save and process">
    Click **Save**. The snippet is queued for chunking, embedding, and indexing — the same processing pipeline as PDFs and URLs.
  </Step>
</Steps>

## Q\&A pairs vs text snippets

These two formats often overlap in subject matter, but they behave very differently. Use this guide to choose the right one.

**Use a Q\&A pair when:**

* You want a single, canonical answer returned word-for-word.
* Wording is high-stakes — regulatory, legal, brand, or scripted.
* The content fits naturally as one question and one answer.
* You want the answer returned even if surrounding documents don't contain it.

**Use a text snippet when:**

* The information is a paragraph or section that the agent should weave into responses with surrounding context.
* The same content might be relevant to many different questions.
* You want the agent to summarize, quote, or combine the snippet with other sources.
* The content doesn't fit neatly as a single question/answer.

At runtime, Q\&A pairs are checked first. If a confident semantic match is found, the user gets your exact answer with no AI paraphrasing. Otherwise the platform falls back to chunk retrieval across PDFs, URLs, and text snippets, and the model generates a response grounded in those chunks.

## Document processing pipeline

After you add a PDF, URL, or text snippet, it moves through a processing pipeline. Q\&A pairs are not part of this pipeline — they are stored and matched directly without chunking.

| Status         | Description                                                             |
| -------------- | ----------------------------------------------------------------------- |
| **Pending**    | The source has been submitted and is queued for processing.             |
| **Processing** | The source is being chunked, embedded, and indexed.                     |
| **Indexed**    | Processing is complete. The source is now available to your agent.      |
| **Error**      | Something went wrong during processing. Check the source and try again. |

<Note>
  The Knowledge Base page automatically checks for status updates every 5 seconds while sources are processing. You'll receive a toast notification when indexing is complete.
</Note>

<Warning>
  Documents may take a few minutes to process depending on their size. Large clinical study reports or lengthy prescribing information documents will take longer than shorter materials.
</Warning>

## Managing sources

Once a source is indexed (or, for Q\&A pairs, saved), you can manage it from the Knowledge Base list:

* **Edit** — Update the question and answer, the snippet content and metadata, or the document name and metadata.
* **Reindex** — For PDFs, URLs, and text snippets, trigger reprocessing if the underlying content has changed. (Q\&A pairs are re-embedded automatically when the question is edited — no manual reindex needed.)
* **Delete** — Permanently remove the source from the Knowledge Base.

<Warning>
  Deleting a source removes it from the agent's knowledge immediately. The agent will no longer be able to reference that content in its responses.
</Warning>

## Best practices

<AccordionGroup>
  <Accordion title="Choose authoritative sources">
    Prioritize approved and authoritative materials — prescribing information, approved labeling, published clinical studies, and regulatory-approved marketing content. The quality of your agent's responses directly reflects the quality of its knowledge base.
  </Accordion>

  <Accordion title="Use Q&A pairs for high-stakes phrasing">
    When wording is regulated, branded, or otherwise must not be paraphrased, write a Q\&A pair. The exact answer is returned to the user verbatim — the model does not rewrite it.
  </Accordion>

  <Accordion title="Keep snippets focused">
    A text snippet should cover a single topic. Tightly scoped snippets produce more coherent chunks, which leads to more accurate retrieval and cleaner responses.
  </Accordion>

  <Accordion title="Cover the way users actually ask">
    Q\&A pair matching is semantic but not magic. If the same question is asked in very different ways, consider adding a Q\&A pair for each phrasing.
  </Accordion>

  <Accordion title="Keep documents up to date">
    When product information changes (new indications, updated safety data, revised labeling), update or replace the relevant sources in your Knowledge Base promptly.
  </Accordion>

  <Accordion title="Use descriptive metadata">
    Accurate metadata helps you manage a growing knowledge base. Use clear, consistent names and always specify the therapeutic area and publication date.
  </Accordion>

  <Accordion title="Monitor for errors">
    Check back after adding a PDF, URL, or text snippet to confirm it reaches **Indexed** status. If a source shows an **Error** status, review it and re-add or reindex if needed.
  </Accordion>
</AccordionGroup>
