Skip to main content
The knowledge command manages document knowledge bases that agents can query for relevant information.

Quick Start

# Add a document
praisonai knowledge add document.pdf

# Search knowledge base
praisonai knowledge search "API authentication"

Commands

Add Documents

# Add a single file
praisonai knowledge add document.pdf

# Add a directory
praisonai knowledge add ./docs/

# Add multiple files
praisonai knowledge add file1.pdf file2.txt file3.md
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      │
└─────────────────────┴──────────────┘

Search Knowledge Base

praisonai knowledge search "How to authenticate API requests"
Expected Output:
🔍 Searching knowledge base...

Found 5 relevant results:

1. [95% match] api-docs.pdf (page 23)
   "Authentication is handled via Bearer tokens. Include the token
   in the Authorization header: Authorization: Bearer <token>"

2. [87% match] security-guide.md (section 3.2)
   "All API requests must be authenticated. Unauthenticated requests
   will receive a 401 Unauthorized response."

3. [82% match] quickstart.txt (line 45)
   "To get started, first obtain an API key from the dashboard..."

4. [76% match] api-docs.pdf (page 25)
   "Token expiration is set to 24 hours by default..."

5. [71% match] faq.md
   "Q: How do I refresh my authentication token?..."

List Documents

praisonai knowledge list
Expected 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 chunks

Show Knowledge Base Info

praisonai knowledge info
Expected 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 clear
Expected Output:
⚠️  This will delete all documents from the knowledge base.
Are you sure? (y/N): y

🗑️  Clearing knowledge base...
✅ Knowledge base cleared successfully!

Help

praisonai knowledge help
Expected Output:
Knowledge Commands:

  praisonai knowledge add <file|dir>     - Add document(s) to knowledge base
  praisonai knowledge search <query>     - Search knowledge base
  praisonai knowledge list               - List indexed documents
  praisonai knowledge clear              - Clear knowledge base
  praisonai knowledge info               - Show knowledge base info

Options:
  --workspace <path>                     - Workspace directory (default: current)

Supported File Types

TypeExtensionsDescription
PDF.pdfPDF documents with text extraction
Markdown.md, .mdxMarkdown files
Text.txtPlain text files
Code.py, .js, .ts, etc.Source code files
HTML.html, .htmWeb pages
JSON.jsonJSON documents
CSV.csvTabular data

Use Cases

# Add project documentation
praisonai knowledge add ./docs/

# Query documentation
praisonai "How do I configure the database?" --knowledge

Code Understanding

# Add codebase
praisonai knowledge add ./src/

# Ask about code
praisonai "Explain the authentication flow" --knowledge

Research 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" --knowledge
Expected 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)

Best Practices

Organize documents by topic in separate directories for better search relevance.
Large documents are automatically chunked. Very large knowledge bases may increase response latency.

Document Quality

Use well-structured documents with clear headings

Regular Updates

Keep knowledge base updated with latest documentation

Specific Queries

Use specific search terms for better results

Organize by Topic

Group related documents together