Skip to main content

Overview

The retrieval CLI provides unified commands for indexing documents and querying knowledge bases. These commands are Agent-first and use the same retrieval pipeline as the Python SDK.

Commands

praisonai index - Index Documents

Index documents into a knowledge base for later retrieval.
# Index a directory
praisonai index ./docs

# Index specific files
praisonai index paper.pdf report.txt

# Index with custom collection name
praisonai index ./data --collection research

# Index with verbose output
praisonai index ./docs --verbose

Options

OptionDescriptionDefault
--collection, -cCollection/knowledge base namedefault
--config, -fConfig file path (YAML)None
--verbose, -vVerbose outputFalse
--profileEnable performance profilingFalse
--profile-outSave profile to JSON fileNone
--profile-topTop N items in profile20

praisonai query - Query with Answer and Citations

Query the knowledge base and get a structured answer with citations.
# Basic query
praisonai query "What are the main findings?"

# Query specific collection
praisonai query "Summarize the document" --collection research

# Query with more results
praisonai query "Key points?" --top-k 10

# Query without citations
praisonai query "Summary?" --no-citations

# Query with hybrid retrieval and reranking
praisonai query "What is the conclusion?" --hybrid --rerank

Options

OptionDescriptionDefault
--collection, -cCollection to querydefault
--top-k, -kNumber of results to retrieve5
--min-scoreMinimum relevance score (0.0-1.0)0.0
--hybridUse hybrid retrieval (dense + keyword)False
--rerankEnable reranking of resultsFalse
--citations/--no-citationsInclude citationsTrue
--citations-modeCitations mode: append, inline, hiddenappend
--max-context-tokensMaximum context tokens4000
--config, -fConfig file pathNone
--verbose, -vVerbose outputFalse
--profileEnable performance profilingFalse
praisonai search picks its mode from the flags you pass:
  • Plain query → web search (OpenAI-style). No LLM synthesis; raw results.
  • Query + any KB flag (--collection/-c, --top-k/-k, --hybrid) → knowledge-base search. Runs against the indexed collection with no LLM synthesis.
# Web search — no KB flags, no LLM synthesis
praisonai search "capital of France"

# KB search — any of --collection / -c / --top-k / -k / --hybrid switches to retrieval
praisonai search "main findings" --collection research --top-k 10

# --collection=value syntax also works
praisonai search "main findings" --collection=research

# Hybrid KB search
praisonai search "key concepts" --hybrid
For LLM-synthesised answers with citations, use praisonai query (above). praisonai search never calls the LLM — it returns raw web hits or raw retrieval hits depending on the flags.

Options — KB-Retrieval Mode

Passing any of --collection, -c, --top-k, -k, or --hybrid switches praisonai search into KB-retrieval mode. The --flag value and --flag=value forms are both accepted.
OptionDescriptionDefault
--collection, -cCollection to searchdefault
--top-k, -kNumber of results to retrieve5
--hybridUse hybrid retrievalFalse
--config, -fConfig file pathNone
--verbose, -vVerbose outputFalse

Options — Web-Search Mode

With no KB-retrieval flag, praisonai search falls back to a web search (the historical default). Only --max-results / -n is honoured; the KB flags are unavailable in this mode.
OptionDescriptionDefault
--max-results, -nMax web-search results5

Examples

Complete Workflow

# 1. Index your documents
praisonai index ./company_docs --collection company

# 2. Query with citations
praisonai query "What is our vacation policy?" --collection company

# 3. Search for specific terms
praisonai search "remote work" --collection company --top-k 10

Using Config Files

Create a config file retrieval.yaml:
knowledge:
  vector_store:
    provider: chroma
    config:
      collection_name: my_docs
      path: .praison/knowledge

retrieval:
  top_k: 10
  rerank: true
  max_context_tokens: 8000
Use with commands:
praisonai index ./docs --config retrieval.yaml
praisonai query "Summary?" --config retrieval.yaml

Performance Profiling

Profile indexing and query performance:
# Profile indexing
praisonai index ./large_corpus --profile --profile-out index_profile.json

# Profile query
praisonai query "Complex question" --profile --profile-out query_profile.json

# View profile results
cat query_profile.json

Verbose Mode

Get detailed output for debugging:
praisonai query "What is the answer?" --verbose
Output includes:
  • Collection being queried
  • Retrieval strategy used
  • Number of sources found
  • Relevance scores
  • Elapsed time

Environment Variables

VariableDescription
OPENAI_API_KEYOpenAI API key for embeddings and generation
ANTHROPIC_API_KEYAnthropic API key (if using Claude)

Comparison with Legacy Commands

The unified retrieval commands replace the separate knowledge and rag command families:
LegacyNew Unified
praisonai knowledge addpraisonai index
praisonai rag querypraisonai query
praisonai knowledge searchpraisonai search "Q" --collection C (a KB flag is required to reach the retrieval path — a bare praisonai search "Q" now runs a web search)
The legacy commands are still available but marked as deprecated. Use the new unified commands for all new projects.

Next Steps