Knowledge CLI
Manage RAG/vector store knowledge bases with advanced retrieval strategies
The knowledge command manages document knowledge bases with support for multiple vector stores, retrieval strategies, rerankers, and query modes.
Quick Start
# List knowledge sources
praisonai knowledge list
# Add a document
praisonai knowledge add document.pdf
# Query knowledge base with RAG
praisonai knowledge query "API authentication"
# Query with advanced options
praisonai knowledge query "How to authenticate?" --retrieval fusion --reranker llmCommands
Add Documents
# Add a single file
praisonai knowledge add document.pdf
# Add a directory
praisonai knowledge add ./docs/
# Add a URL
praisonai knowledge add https://example.com/docs.html
# Add with glob pattern
praisonai knowledge add "*.pdf"Expected Output:
๐ Adding documents to knowledge base...
โ
Added: document.pdf
โข Pages: 45
โข Chunks: 128
โข Vectors: 128
Knowledge base updated successfully!
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโ
โ Metric โ Value โ
โโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ Total Documents โ 12 โ
โ Total Chunks โ 1,456 โ
โ Storage Size โ 24.5 MB โ
โโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโQuery Knowledge Base
# Basic query
praisonai knowledge query "How to authenticate API requests"
# Query with specific vector store
praisonai knowledge query "authentication" --vector-store chroma
# Query with fusion retrieval (multi-query)
praisonai knowledge query "How to authenticate?" --retrieval fusion
# Query with LLM reranking
praisonai knowledge query "API auth" --reranker llm
# Query with sub-question decomposition
praisonai knowledge query "What is Python and how to install it?" --query-mode sub_question
# Full advanced query
praisonai knowledge query "authentication flow" \
--vector-store chroma \
--retrieval fusion \
--reranker llm \
--index-type hybrid \
--query-mode sub_questionExpected Output:
๐ Querying knowledge base...
Found 5 relevant results:
1. [score: 0.95] api-docs.pdf (page 23)
"Authentication is handled via Bearer tokens. Include the token
in the Authorization header: Authorization: Bearer <token>"
2. [score: 0.87] security-guide.md (section 3.2)
"All API requests must be authenticated. Unauthenticated requests
will receive a 401 Unauthorized response."
3. [score: 0.82] quickstart.txt (line 45)
"To get started, first obtain an API key from the dashboard..."Search Knowledge Base
Unlike query, search returns raw ranked results with no LLM answer generation.
praisonai knowledge search "capital of France" --user-id myuserSee Knowledge CLI for the full flag reference, and Search Results for the SearchResult shape returned when calling Knowledge.search() from Python.
List Documents
praisonai knowledge listExpected Output:
๐ Knowledge Base Contents:
โโโโโโฌโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโ
โ # โ Document โ Type โ Chunks โ Added โ
โโโโโโผโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโค
โ 1 โ api-docs.pdf โ PDF โ 234 โ 2024-12-15 10:30 โ
โ 2 โ security-guide.md โ Markdown โ 45 โ 2024-12-15 10:32 โ
โ 3 โ quickstart.txt โ Text โ 12 โ 2024-12-15 10:33 โ
โ 4 โ faq.md โ Markdown โ 28 โ 2024-12-16 09:15 โ
โ 5 โ architecture.pdf โ PDF โ 156 โ 2024-12-16 14:20 โ
โโโโโโดโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโ
Total: 5 documents, 475 chunksShow Knowledge Base Info
praisonai knowledge infoExpected Output:
๐ Knowledge Base Information:
โโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Property โ Value โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Location โ .praison/knowledge/ โ
โ Vector Store โ ChromaDB โ
โ Embedding Model โ text-embedding-3-small โ
โ Total Documents โ 5 โ
โ Total Chunks โ 475 โ
โ Total Vectors โ 475 โ
โ Storage Size โ 12.3 MB โ
โ Last Updated โ 2024-12-16 14:20:00 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโClear Knowledge Base
# Clear all documents
praisonai knowledge clearExpected Output:
โ ๏ธ This will delete all documents from the knowledge base.
Are you sure? (y/N): y
๐๏ธ Clearing knowledge base...
โ
Knowledge base cleared successfully!Show Statistics
praisonai knowledge statsExpected Output:
๐ Knowledge Base Statistics:
workspace: /path/to/project
vector_store: chroma
retrieval_strategy: basic
reranker: none
index_type: vector
query_mode: default
document_count: 5Export Knowledge Base
# Export to default timestamped file
praisonai knowledge export
# Export to specific file
praisonai knowledge export backup.json
# Export to specific path
praisonai knowledge export /path/to/knowledge_backup.jsonExpected Output:
โ
Exported 12 documents to knowledge_export_20241226_103045.jsonImport Knowledge Base
# Import from JSON file
praisonai knowledge import backup.json
# Import from specific path
praisonai knowledge import /path/to/knowledge_backup.jsonExpected Output:
โ
Imported 12 documents from backup.jsonHelp
praisonai knowledge helpExpected Output:
Knowledge Commands:
praisonai knowledge add <file|dir|url> - Add document(s) to knowledge base
praisonai knowledge query <question> - Query knowledge base with RAG
praisonai knowledge list - List indexed documents
praisonai knowledge clear - Clear knowledge base
praisonai knowledge stats - Show knowledge base statistics
praisonai knowledge export <file.json> - Export knowledge base to JSON file
praisonai knowledge import <file.json> - Import knowledge base from JSON file
Options:
--workspace <path> - Workspace directory (default: current)
--vector-store <name> - Vector store: chroma, pinecone, qdrant, weaviate, memory
--retrieval <strategy> - Retrieval: basic, fusion, recursive, auto_merge
--reranker <name> - Reranker: simple, llm, cross_encoder, cohere
--index-type <type> - Index: vector, keyword, hybrid
--query-mode <mode> - Query: default, sub_question, summarize
--session <id> - Session ID for persistence
--db <path> - Database path for persistenceAdvanced Options Reference
Vector Stores
| Store | Description | Requirements |
|---|---|---|
memory | In-memory (default, no persistence) | None |
chroma | ChromaDB local vector store | pip install chromadb |
pinecone | Pinecone cloud vector store | PINECONE_API_KEY |
qdrant | Qdrant vector database | pip install qdrant-client |
weaviate | Weaviate vector database | pip install weaviate-client |
Retrieval Strategies
| Strategy | Description |
|---|---|
basic | Simple vector similarity search (default) |
fusion | Multi-query with Reciprocal Rank Fusion |
recursive | Depth-limited recursive retrieval |
auto_merge | Merges adjacent chunks from same document |
Rerankers
| Reranker | Description | Requirements |
|---|---|---|
simple | Keyword-based scoring (default) | None |
llm | LLM-based relevance scoring | OPENAI_API_KEY |
cross_encoder | Cross-encoder model | pip install sentence-transformers |
cohere | Cohere Rerank API | COHERE_API_KEY |
Index Types
| Type | Description |
|---|---|
vector | Vector similarity index (default) |
keyword | BM25 keyword index |
hybrid | Combined vector + keyword |
Query Modes
| Mode | Description |
|---|---|
default | Standard RAG query |
sub_question | Decomposes complex questions |
summarize | Summarizes retrieved context |
Supported File Types
| Type | Extensions | Description |
|---|---|---|
.pdf | PDF documents with text extraction | |
| Markdown | .md, .mdx | Markdown files |
| Text | .txt | Plain text files |
| Code | .py, .js, .ts, etc. | Source code files |
| HTML | .html, .htm | Web pages |
| JSON | .json | JSON documents |
| CSV | .csv | Tabular data |
| URL | http://, https:// | Web pages |
Use Cases
Documentation Search
# Add project documentation
praisonai knowledge add ./docs/
# Query documentation
praisonai "How do I configure the database?" --knowledgeCode Understanding
# Add codebase
praisonai knowledge add ./src/
# Ask about code
praisonai "Explain the authentication flow" --knowledgeResearch Assistant
# Add research papers
praisonai knowledge add ./papers/
# Query research
praisonai knowledge search "machine learning optimization techniques"Using Knowledge with Agents
Once documents are added, agents can automatically query the knowledge base:
# Enable knowledge for agent
praisonai "Answer based on the documentation" --knowledgeExpected Output:
๐ Knowledge base enabled (5 documents)
โญโ Agent Info โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ ๐ค Agent: DirectAgent โ
โ Role: Assistant โ
โ ๐ Knowledge: 5 documents, 475 chunks โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Response โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Based on the documentation, here's how to configure the database: โ
โ โ
โ 1. Set the DATABASE_URL environment variable... โ
โ [Response based on knowledge base content] โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
๐ Sources:
โข api-docs.pdf (page 12)
โข quickstart.txt (section 2)Commands Overview
| Command | Description |
|---|---|
index | Add/index documents into a knowledge base |
search | Search/retrieve from knowledge base |
add | Alias for index |
list | List available knowledge bases |
Index Command
Add documents to a knowledge base.
praisonai knowledge index [OPTIONS] SOURCES...Arguments
| Argument | Description |
|---|---|
SOURCES | Source files, directories, or URLs to index (required) |
Options
| Option | Short | Description | Default |
|---|---|---|---|
--collection | -c | Collection/knowledge base name | default |
--user-id | -u | User ID for scoping (required for mem0) | None |
--agent-id | -a | Agent ID for scoping | None |
--run-id | -r | Run ID for scoping | None |
--backend | -b | Knowledge backend: mem0, chroma, internal | mem0 |
--config | -f | Config file path | None |
--verbose | -v | Verbose output | False |
--profile | Enable performance profiling | False | |
--profile-out | Save profile to JSON file | None |
Examples
# Index a directory with user scope
praisonai knowledge index ./docs --user-id myuser
# Index with specific collection and agent scope
praisonai knowledge index paper.pdf --collection research --agent-id research_agent
# Index using chroma backend
praisonai knowledge index ./data --backend chroma
# Index with profiling
praisonai knowledge index ./docs --user-id myuser --profile --profile-out ./profile.json# When embedding fails (e.g. bad OPENAI_API_KEY or wrong model), the index
# command now exits with a non-zero status so shell pipelines can detect it:
$ praisonai knowledge index ./docs --user-id myuser
โ Failed to index ./docs: no chunks stored (no supported files found, or content could not be extracted)
Indexing failed for 1 of 1 source(s). Collection: default
$ echo $?
1Exit Codes
| Code | Meaning |
|---|---|
0 | Every source produced at least one stored chunk. |
1 | One or more sources produced no chunks โ check the per-source โ lines above the summary. Common causes: unsupported file types in the directory, unreadable content, or an embedding failure (see Troubleshooting). |
Chain commands with praisonai knowledge index โฆ && โฆ to run the next step only when every source indexes successfully.
Search Command
Search/retrieve from a knowledge base without LLM generation.
praisonai knowledge search [OPTIONS] QUERYArguments
| Argument | Description |
|---|---|
QUERY | Search query (required) |
Options
| Option | Short | Description | Default |
|---|---|---|---|
--collection | -c | Collection to search | default |
--user-id | -u | User ID for scoping (required for mem0) | None |
--agent-id | -a | Agent ID for scoping | None |
--run-id | -r | Run ID for scoping | None |
--backend | -b | Knowledge backend: mem0, chroma, internal | mem0 |
--top-k | -k | Number of results to retrieve | 5 |
--hybrid | Use hybrid retrieval (dense + BM25) | False | |
--config | -f | Config file path | None |
--verbose | -v | Verbose output | False |
--profile | Enable performance profiling | False |
Examples
# Basic search with user scope
praisonai knowledge search "capital of France" --user-id myuser
# Search specific collection with more results
praisonai knowledge search "main findings" --collection research --top-k 10
# Hybrid search using chroma backend
praisonai knowledge search "Python tutorial" --hybrid --backend chroma
# Search with agent scope
praisonai knowledge search "company policy" --agent-id company_botOutput
Results print as a Rich table with #, Score, Source, and Content columns:
โโโโโณโโโโโโโโณโโโโโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ # โ Score โ Source โ Content โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ 1 โ 0.95 โ geography.txt โ Paris is the capital of France. โ
โ 2 โ 0.82 โ europe.md โ France is a country in Europe. โ
โโโโโดโโโโโโโโดโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโWhen nothing matches, the command prints:
No results found.If search consistently returns No results found. for content you just indexed, the embedding call likely failed silently on an older build. Upgrade to the latest release (PR #2823), where indexing errors exit non-zero and print โ Failed to index โฆ. See Troubleshooting.
Result normalisation
The CLI accepts results from all three backend return shapes โ a typed SearchResult, a legacy dict with a "results" key, or a plain list. Custom backends don’t have to pick one format; the command normalises them all before display.
See Search Results for the SearchResult shape and how to consume it from Python.
List Command
List available knowledge bases/collections.
praisonai knowledge list [OPTIONS]Options
| Option | Short | Description | Default |
|---|---|---|---|
--verbose | -v | Verbose output | False |
Example
praisonai knowledge listOutput:
โโโโโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Collection โ Path โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ default โ ./.praison/knowledge/default โ
โ research โ ./.praison/knowledge/research โ
โโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโScope Identifiers
When to Use Each Scope
| Scope | Use Case | Example |
|---|---|---|
--user-id | Per-user knowledge isolation | Multi-tenant apps |
--agent-id | Shared agent knowledge | Company FAQ bot |
--run-id | Session-specific context | Conversation history |
Backend Selection
mem0 (Default)
Best for production apps with multi-user support:
praisonai knowledge index ./docs --user-id alice --backend mem0Chroma
Best for local development:
praisonai knowledge index ./docs --backend chromaInternal
Lightweight built-in storage:
praisonai knowledge index ./docs --backend internalBest Practices
Use well-structured documents with clear headings
Regular UpdatesKeep knowledge base updated with latest documentation
Specific QueriesUse specific search terms for better results
Organize by TopicGroup related documents together