The rf kb command provides complete knowledge base (vector store) management for RAG applications. Upload documents, perform semantic search, check processing status, and manage your knowledge bases.
Commands Overview
Command Description rf kb listList all knowledge bases rf kb create <name>Create new knowledge base rf kb upload <kb> <file/dir>Upload documents rf kb status <kb>Check processing status rf kb docs <kb>List documents in KB rf kb remove-doc <kb> <doc-id>Remove specific document rf kb search <kb> <query>Semantic search rf kb delete <kb>Delete knowledge base
Listing Knowledge Bases
# List all knowledge bases
rf kb list
# Output:
# Knowledge Bases:
# • support-docs (100 documents)
# • product-manual (45 documents)
# • faq-knowledge (12 documents)
Creating Knowledge Base
Interactive Mode
rf kb create support-docs
# → Select embedding configuration:
# • OpenAI Small (text-embedding-3-small)
# • OpenAI Large (text-embedding-3-large)
# • Custom...
# ✓ Knowledge base 'support-docs' created
Non-Interactive Mode
Perfect for scripts and automation:
# Using embedding name
rf kb create support-docs --embedding "OpenAI Small"
# Using short form
rf kb create support-docs -e openai-small
# Using embedding config ID
rf kb create support-docs --embedding embedding-cfg-123
Options
Option Alias Description --embedding <config>-eEmbedding config ID or name --yes-ySkip confirmations
Uploading Documents
Upload Single File
# Upload one file
rf kb upload support-docs ./manual.pdf
# ✓ Uploaded: manual.pdf
# Supported formats
rf kb upload support-docs ./faq.txt
rf kb upload support-docs ./guide.md
rf kb upload support-docs ./doc.docx
Upload Directory
# Upload all files in directory (with confirmation)
rf kb upload support-docs ./docs
# ? Upload 15 files from ./docs? (y/N)
# Skip confirmation
rf kb upload support-docs ./docs --yes
# ✓ Uploaded 15 files
Supported File Types
PDF (.pdf)
Text (.txt)
Markdown (.md)
Word Documents (.docx)
Files are automatically parsed, chunked, and embedded for semantic search.
Checking Processing Status
# Check if documents are processed
rf kb status support-docs
# Output:
# Knowledge Base: support-docs
# Status: Processing
# Documents: 15 total, 12 processed, 3 pending
# Embedding: OpenAI Small
Statuses:
Processing - Documents being embedded
Ready - All documents processed
Error - Some documents failed
Listing Documents
# List all documents in KB
rf kb docs support-docs
# Output:
# Documents in support-docs:
# • doc_abc123 - manual.pdf (1.2 MB, 45 chunks)
# • doc_def456 - faq.txt (50 KB, 12 chunks)
# • doc_ghi789 - guide.md (200 KB, 28 chunks)
Removing Documents
# Remove with confirmation
rf kb remove-doc support-docs doc_abc123
# ? Are you sure you want to remove document 'doc_abc123'? (y/N)
# Remove without confirmation
rf kb remove-doc support-docs doc_abc123 --yes
# ✓ Document removed
# Short form
rf kb remove-doc support-docs doc_abc123 -y
Removing a document is permanent and cannot be undone!
Semantic Search
Test your knowledge base with semantic search:
# Search for relevant content
rf kb search support-docs "how to reset password"
# Output:
# Search Results:
#
# [1] Score: 0.92
# Source: faq.txt
# Content: To reset your password, go to Settings > Security...
#
# [2] Score: 0.87
# Source: manual.pdf
# Content: Password Reset Procedure: 1. Click Forgot Password...
#
# [3] Score: 0.81
# Source: guide.md
# Content: User accounts can be recovered by...
Search Features:
Semantic similarity (not just keyword matching)
Ranked by relevance score (0-1)
Shows source document
Returns top relevant chunks
Deleting Knowledge Base
# Delete with confirmation
rf kb delete support-docs
# ? Are you sure you want to delete knowledge base 'support-docs'? (y/N)
# Delete without confirmation
rf kb delete support-docs --yes
# ✓ Knowledge base deleted
# Short form
rf kb delete support-docs -y
Deleting a knowledge base removes all documents and embeddings permanently!
Complete Workflow Example
# 1. Create knowledge base
rf kb create support-docs --embedding "OpenAI Small"
# 2. Upload documents
rf kb upload support-docs ./docs/manual.pdf
rf kb upload support-docs ./docs/faq.md
rf kb upload support-docs ./docs --yes
# 3. Check processing status
rf kb status support-docs
# Wait until status is "Ready"
# 4. Test semantic search
rf kb search support-docs "how to install"
rf kb search support-docs "pricing information"
rf kb search support-docs "troubleshooting errors"
# 5. List all documents
rf kb docs support-docs
# 6. Remove outdated document
rf kb remove-doc support-docs doc_old123 --yes
# 7. Use in your agent
cd my-agent/
rf test
# → Agent now has access to support-docs knowledge base
Using with RAG Agents
Creating RAG Agent with Knowledge Base
# 1. Create agent from RAG template
rf create --name support-bot --template rag-agent --yes
# 2. Create and populate knowledge base
rf kb create support-knowledge --embedding "OpenAI Small"
rf kb upload support-knowledge ./company-docs --yes
# 3. Test locally
cd support-bot/
rf test
# 4. Deploy
rf agents deploy
Agent Configuration
Your agent code will reference the knowledge base:
import { Agent } from '@runflow-ai/core' ;
const agent = new Agent ({
name: 'Support Bot' ,
instructions: 'Use the knowledge base to answer questions' ,
knowledgeBase: 'support-knowledge' , // Reference your KB
model: 'gpt-4' ,
});
Automation & Scripts
Bulk Upload Script
#!/bin/bash
# Create KB
rf kb create product-docs --embedding "OpenAI Small"
# Upload all PDFs
find ./documents -name "*.pdf" -exec rf kb upload product-docs {} \;
# Wait for processing
while [ "$( rf kb status product-docs | grep 'Status:' | awk '{print $2}')" != "Ready" ]; do
echo "Processing..."
sleep 5
done
echo "Knowledge base ready!"
Multi-KB Setup
#!/bin/bash
# Setup multiple knowledge bases
kb_configs = (
"support-docs:./support-files"
"product-manual:./manuals"
"legal-docs:./legal"
)
for config in "${ kb_configs [ @ ]}" ; do
kb_name = "${ config %%:* }"
kb_dir = "${ config ##*: }"
rf kb create " $kb_name " --embedding "OpenAI Small"
rf kb upload " $kb_name " " $kb_dir " --yes
done
Best Practices
1. Organize Documents by Domain
# Create separate KBs for different topics
rf kb create customer-support
rf kb create product-documentation
rf kb create legal-compliance
rf kb create internal-wiki
2. Keep Documents Updated
# Remove old versions
rf kb remove-doc support-docs doc_old_manual --yes
# Upload new versions
rf kb upload support-docs ./manual-v2.pdf
3. Test Before Production
# Always test search quality
rf kb search my-kb "common query 1"
rf kb search my-kb "common query 2"
rf kb search my-kb "edge case query"
# Refine documents if results are poor
4. Choose Appropriate Embedding Model
# Small model - faster, cheaper, good for most use cases
rf kb create kb-small --embedding "OpenAI Small"
# Large model - more accurate, better for complex domains
rf kb create kb-large --embedding "OpenAI Large"
5. Monitor Processing Status
# After large uploads, monitor status
rf kb upload docs ./large-dataset --yes
rf kb status docs
# Wait for processing to complete before using
Document Processing
How It Works
Upload - File sent to server
Parse - Content extracted (text from PDF, DOCX, etc.)
Chunk - Split into manageable pieces (~500 tokens)
Embed - Generate vector embeddings
Index - Store in vector database
Ready - Available for search
Processing Time
Small files (<1 MB): ~5-10 seconds
Medium files (1-10 MB): ~30-60 seconds
Large files (>10 MB): ~2-5 minutes
Directories: Depends on total size and file count
Chunking Strategy
Documents are automatically chunked with:
Chunk size : ~500 tokens (~375 words)
Overlap : 50 tokens (for context continuity)
Smart splitting : Respects paragraph boundaries
Troubleshooting
KB Already Exists
rf kb create existing-kb
# Error: Knowledge base 'existing-kb' already exists
Solution: Use a different name or delete the existing KB:
rf kb delete existing-kb --yes
rf kb create existing-kb --embedding "OpenAI Small"
Upload Failed
rf kb upload docs ./file.pdf
# Error: Failed to upload file
Possible causes:
File format not supported
File too large (>50 MB)
Network connection issues
Solution:
Check file format (PDF, TXT, MD, DOCX only)
Split large files
Retry upload
Documents Stuck in Processing
rf kb status docs
# Status: Processing (stuck for 30+ minutes)
Solution:
Check document format and content
Contact support if issue persists
Remove and re-upload problematic documents
Poor Search Results
If search quality is low:
Add more documents - More context improves results
Use larger embedding model - Better semantic understanding
Improve document quality - Clear, well-structured content
Test queries - Refine search terms
# Try different embedding
rf kb create kb-improved --embedding "OpenAI Large"
rf kb upload kb-improved ./docs --yes
rf kb search kb-improved "test query"
Advanced Usage
Environment-Specific KBs
# Development KB with test data
rf switch dev
rf kb create test-kb --embedding "OpenAI Small"
rf kb upload test-kb ./test-data --yes
# Production KB with real data
rf switch prod
rf kb create prod-kb --embedding "OpenAI Large"
rf kb upload prod-kb ./production-data --yes
Backup and Restore
# Document metadata can be exported via API
# (CLI backup feature coming soon)
# For now, keep source files backed up
cp -r ./original-docs ./backup- $( date +%Y%m%d )
Next Steps
Create RAG Agent Create agent with knowledge base
Test Locally Test KB integration locally
Prompts Create RAG-specific prompts
Knowledge & RAG Learn more about RAG concepts