RAG CLI
Thepraisonai rag command group provides full RAG functionality from the command line.
Commands
index
Build or update an index from source documents.sources- Files, directories, or URLs to index
--collection, -c- Collection name (default: “default”)--chunking- Chunking strategy: token, sentence, recursive, semantic--chunk-size- Chunk size in tokens (default: 512)--config, -f- Config file path--verbose, -v- Verbose output--profile- Enable performance profiling--profile-out- Save profile to JSON file--profile-top- Top N items in profile (default: 20)
This command uses the Knowledge substrate for indexing. Equivalent to
praisonai knowledge index.--chunking and --chunk-size reach the Knowledge chunker directly. --chunking accepts token, sentence, recursive (default), or semantic; --chunk-size defaults to 512 tokens.Chunker precedence with --config
CLI chunker flags and a config file’s chunker block merge field by field — a file overrides only the fields it sets, leaving the other CLI value intact.
Given praisonai rag index ./data --chunking semantic --chunk-size 256 --config cfg.yaml:
Exit codes for rag index
rag index exits 1 when any source stores zero chunks — a broken embedding backend, an empty glob, or an unreadable directory no longer looks like a successful import.
The zero-chunk outcome is the CLI surface of the SDK’s
result["errors"] behaviour. See Knowledge Indexing Errors for the underlying failure modes (wrong embedding model name, revoked API key, exhausted quota).
query
One-shot question answering with citations.--collection, -c- Collection to query (default: “default”)--top-k, -k- Number of results (default: 5)--hybrid- Use hybrid retrieval (dense + BM25)--rerank- Enable reranking of results--citations/--no-citations- Include citations (default: true)--config, -f- Config file path--verbose, -v- Verbose output--profile- Enable performance profiling--profile-out- Save profile to JSON file--profile-top- Top N items in profile (default: 20)
chat
Interactive RAG chat session with streaming.--collection, -c- Collection to chat with (default: “default”)--top-k, -k- Results per query (default: 5)--hybrid- Use hybrid retrieval (dense + BM25)--rerank- Enable reranking of results--config, -f- Config file path--stream/--no-stream- Stream responses (default: true)
- Type questions to get answers
exit,quit, orqto end sessionCtrl+Cto interrupt
eval
Evaluate RAG retrieval quality against golden queries.test_file- JSON file with test queries
--collection, -c- Collection to evaluate (default: “default”)--top-k, -k- Results to retrieve (default: 5)--output, -o- Output results to file--verbose, -v- Verbose output--profile- Enable performance profiling--profile-out- Save profile to JSON file--profile-top- Top N items in profile (default: 20)
serve
Start RAG as a microservice API.--collection, -c- Collection to serve (default: “default”)--host, -h- Host to bind (default: 127.0.0.1)--port, -p- Port to bind (default: 8080)--hybrid- Use hybrid retrieval (dense + BM25)--rerank- Enable reranking of results--openai-compat- Enable OpenAI-compatible/v1/chat/completionsendpoint--config, -f- Config file path--verbose, -v- Verbose output--profile- Enable performance profiling--profile-out- Save profile to JSON file--profile-top- Top N items in profile (default: 20)
Query Request:
Configuration File
Create a YAML config file for reusable settings:The
Knowledge chunker reads three keys under knowledge.chunker: type (default recursive), chunk_size (default 512), and chunk_overlap (default 50). type accepts token, sentence, recursive, or semantic.Configuration Precedence
Settings are applied in this order (highest priority first):- CLI flags -
--hybrid,--rerank,--top-k, etc. - Environment variables -
PRAISONAI_HYBRID=true, etc. - Config file - YAML configuration
- Defaults - Built-in defaults
Environment Variables
Override settings with environment variables:Exit Codes
For
rag index, 0 means every source stored at least one chunk and 1 means at least one source stored zero chunks or raised — see Exit codes for rag index.
Knowledge vs RAG
Knowledge is the indexing and retrieval substrate:- Indexes documents into vector stores
- Performs similarity search
- Returns raw chunks/documents
- Use
praisonai knowledgefor indexing and search without LLM generation
- Retrieves context using Knowledge
- Generates answers with an LLM
- Provides citations
- Use
praisonai ragfor question answering with generated responses
knowledge index and query with rag query.
Tips
- Start simple: Use defaults, then customize
- Use hybrid retrieval:
--hybridcombines dense + keyword search for better recall - Enable reranking:
--rerankimproves precision for complex queries - Name collections: Organize by project or topic
- Use config files: For reproducible setups
- Check verbose output: Debug retrieval issues
- Profile performance: Use
--profileto identify bottlenecks - Evaluate regularly: Track quality over time

