Knowledge Base
Enhance your agents with document-based knowledge using Retrieval-Augmented Generation (RAG).
Overview
The Knowledge Base allows you to:
- Upload documents (PDF, TXT, MD, etc.)
- Automatically chunk and embed content
- Query semantically for relevant context
- Connect to agents for enhanced responses
Quick Start
Dashboard
Navigate to Dashboard → Knowledge for the visual interface.
API
cURL
# Upload a document
curl -X POST "https://cloud.milady.ai/api/v1/knowledge/upload-file" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@document.pdf" \
-F "agentId=agent_abc123"Supported Formats
| Format | Extension | Max Size |
|---|---|---|
.pdf | 5MB | |
| Text | .txt | 5MB |
| Markdown | .md | 5MB |
| Word | .docx | 5MB |
| JSON | .json | 5MB |
| XML | .xml | 5MB |
| YAML | .yaml | 5MB |
| CSV | .csv | 5MB |
Note: Maximum 5MB per file and 5MB total per batch upload.
Upload Documents
Prepare Your Documents
Ensure documents are in a supported format and within size limits.
Upload via Dashboard or API
Use the Knowledge dashboard or the upload API endpoint.
Wait for Processing
Documents are automatically chunked and embedded.
Connect to Agent
Link the knowledge base to your agent for RAG.
Upload Response
{
"id": "doc_abc123",
"filename": "product-manual.pdf",
"status": "processing",
"chunks": null,
"createdAt": "2024-01-15T10:30:00Z"
}Check Processing Status
curl -X GET "https://cloud.milady.ai/api/v1/knowledge/check?documentId=doc_abc123" \
-H "Authorization: Bearer YOUR_API_KEY"{
"id": "doc_abc123",
"status": "completed",
"chunks": 42,
"tokensUsed": 15234
}Query Knowledge
Search your knowledge base semantically:
curl -X POST "https://cloud.milady.ai/api/v1/knowledge/query" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "How do I reset my password?",
"agentId": "agent_abc123",
"limit": 5
}'Response
{
"results": [
{
"content": "To reset your password, navigate to Settings > Security > Reset Password...",
"score": 0.92,
"documentId": "doc_abc123",
"metadata": {
"page": 15,
"section": "Account Settings"
}
},
{
"content": "Password requirements include at least 8 characters...",
"score": 0.85,
"documentId": "doc_abc123",
"metadata": {
"page": 16,
"section": "Security"
}
}
]
}Managing Documents
List Documents
curl -X GET "https://cloud.milady.ai/api/v1/knowledge?agentId=agent_abc123" \
-H "Authorization: Bearer YOUR_API_KEY"Get Document Details
curl -X GET "https://cloud.milady.ai/api/v1/knowledge/doc_abc123" \
-H "Authorization: Bearer YOUR_API_KEY"Delete Document
curl -X DELETE "https://cloud.milady.ai/api/v1/knowledge/doc_abc123" \
-H "Authorization: Bearer YOUR_API_KEY"RAG Configuration
Chunk Settings
Configure how documents are split:
| Setting | Default | Description |
|---|---|---|
chunkSize | 1000 | Characters per chunk |
chunkOverlap | 200 | Overlap between chunks |
minChunkSize | 100 | Minimum chunk size |
Retrieval Settings
Configure query behavior:
| Setting | Default | Description |
|---|---|---|
limit | 5 | Number of results |
minScore | 0.7 | Minimum relevance score |
rerank | true | Re-rank results for relevance |
Agent Integration
Automatic RAG
When knowledge is connected to an agent, relevant context is automatically retrieved:
// Agent with knowledge base
const response = await fetch("https://cloud.milady.ai/api/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "agent_abc123", // Agent with connected knowledge
messages: [{ role: "user", content: "How do I reset my password?" }],
}),
});The agent automatically queries the knowledge base and includes relevant context in its response.
Manual RAG
Query knowledge and inject context manually:
// 1. Query knowledge
const knowledge = await fetch("https://cloud.milady.ai/api/v1/knowledge/query", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
query: "password reset",
limit: 3,
}),
}).then((r) => r.json());
// 2. Include in chat
const context = knowledge.results.map((r) => r.content).join("\n\n");
const response = await fetch("https://cloud.milady.ai/api/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-4o",
messages: [
{ role: "system", content: `Use this context:\n\n${context}` },
{ role: "user", content: "How do I reset my password?" },
],
}),
});Pricing
See Billing & Credits for current pricing on document uploads, embeddings, queries, and storage.
Best Practices
- Quality Content — Use well-structured, accurate documents
- Organize — Group related documents for better retrieval
- Update Regularly — Keep knowledge current by refreshing documents
- Test Queries — Verify retrieval quality before production