Skip to main content
A knowledge base lets your agent answer questions grounded in your own content. When a user asks something, the platform retrieves the most relevant passages from your documents and injects them into the context before the LLM responds. This is retrieval-augmented generation (RAG), and it significantly reduces hallucination for domain-specific questions.

Document types

You can add content to a knowledge base in three ways:
TypeSupported formatsMax size
FilePDF, TXT, DOCX, HTML, EPUB21 MB per file
URLAny publicly accessible web page
TextPlain text pasted directly
On non-enterprise plans, the total knowledge base size per agent is limited to 20 MB or 300,000 characters, whichever is reached first.

Add documents via dashboard

1

Open your agent

Go to the XUNA AI dashboard and select your agent.
2

Navigate to Knowledge base

Click the Knowledge base tab in the agent settings.
3

Add a document

Click Add document and choose File, URL, or Text. Fill in the required fields and click Save.
4

Verify indexing

The document status changes from Indexing to Ready when retrieval is available. Large files may take a minute or two.

Add documents via API

Create documents and attach them to an agent programmatically using the Python SDK.
from xuna_ai import XunaAI

client = XunaAI()

# Create a document from text
doc_text = client.conversational_ai.knowledge_base.documents.create_from_text(
    text="The airspeed velocity of an unladen swallow is 24 mph.",
    name="Unladen Swallow facts",
)
After creating documents, attach them to your agent:
attach-to-agent.py
from xuna_ai import XunaAI

client = XunaAI()

agent = client.conversational_ai.agents.update(
    agent_id="your-agent-id",
    conversation_config={
        "agent": {
            "prompt": {
                "knowledge_base": [
                    {"type": "text", "name": doc_text.name, "id": doc_text.id},
                    {"type": "url", "name": doc_url.name, "id": doc_url.id},
                    {"type": "file", "name": doc_file.name, "id": doc_file.id},
                ]
            }
        }
    }
)

Best practices

Rather than uploading one large document, split content into smaller, focused files. Retrieval works by matching user queries to document chunks — smaller, topic-focused documents improve match quality.
Name documents clearly (e.g., “Return policy — US”, “Product specs — Model X”). The retriever uses document names as signals during ranking.
URL-based documents are fetched and indexed at creation time, not on every conversation. Re-add the document if the source page changes significantly.
Use the knowledge base for reference content (FAQs, product specs, policies). Keep behavioral instructions in the system prompt — they are always in context, not retrieved.
After adding documents, start a test conversation and ask questions that should be answered from the knowledge base. Check the conversation transcript to see which passages were retrieved.