Skip to main content

RAG CLI

The praisonai rag command group provides full RAG functionality from the command line.

Commands

index

Build or update an index from source documents.
Arguments:
  • sources - Files, directories, or URLs to index
Options:
  • --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.
Examples:

query

One-shot question answering with citations.
Options:
  • --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)
Examples:

chat

Interactive RAG chat session with streaming.
Options:
  • --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)
Examples:
Chat Commands:
  • Type questions to get answers
  • exit, quit, or q to end session
  • Ctrl+C to interrupt

eval

Evaluate RAG retrieval quality against golden queries.
Arguments:
  • test_file - JSON file with test queries
Options:
  • --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)
Test File Format:
Examples:

serve

Start RAG as a microservice API.
Options:
  • --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/completions endpoint
  • --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)
Examples:
API Endpoints: Query Request:

Configuration File

Create a YAML config file for reusable settings:
Use with any command:

Configuration Precedence

Settings are applied in this order (highest priority first):
  1. CLI flags - --hybrid, --rerank, --top-k, etc.
  2. Environment variables - PRAISONAI_HYBRID=true, etc.
  3. Config file - YAML configuration
  4. Defaults - Built-in defaults
This means CLI flags always override environment variables, which override config file settings.

Environment Variables

Override settings with environment variables:

Exit Codes

Knowledge vs RAG

Knowledge is the indexing and retrieval substrate:
  • Indexes documents into vector stores
  • Performs similarity search
  • Returns raw chunks/documents
  • Use praisonai knowledge for indexing and search without LLM generation
RAG orchestrates on top of Knowledge:
  • Retrieves context using Knowledge
  • Generates answers with an LLM
  • Provides citations
  • Use praisonai rag for question answering with generated responses
Both share the same underlying index. You can index with knowledge index and query with rag query.

Tips

  1. Start simple: Use defaults, then customize
  2. Use hybrid retrieval: --hybrid combines dense + keyword search for better recall
  3. Enable reranking: --rerank improves precision for complex queries
  4. Name collections: Organize by project or topic
  5. Use config files: For reproducible setups
  6. Check verbose output: Debug retrieval issues
  7. Profile performance: Use --profile to identify bottlenecks
  8. Evaluate regularly: Track quality over time