Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
RAG Quickstart
Get up and running with RAG in just a few steps.
Installation
pip install praisonaiagents
For full RAG support with vector stores:
pip install "praisonaiagents[knowledge]"
Method 1: Agent with Knowledge (Recommended)
The simplest way to use RAG is through the Agent’s knowledge parameter:
from praisonaiagents import Agent
# Create agent with knowledge sources
agent = Agent(
name="Research Assistant",
instructions="You are a helpful research assistant.",
knowledge=["paper.pdf", "docs/"], # Files or directories
)
# Ask questions - RAG happens automatically
response = agent.start("What are the main conclusions?")
print(response)
Method 2: Explicit RAG Pipeline
For more control, use the RAG class directly:
from praisonaiagents import Knowledge, RAG, RAGConfig
# 1. Create and populate knowledge base
knowledge = Knowledge()
knowledge.add("research_paper.pdf")
knowledge.add("data_analysis.csv")
# 2. Create RAG pipeline
rag = RAG(
knowledge=knowledge,
config=RAGConfig(
top_k=5,
include_citations=True,
)
)
# 3. Query with citations
result = rag.query("What methodology was used?")
print(result.answer)
print("\nSources:")
for citation in result.citations:
print(f" [{citation.id}] {citation.source}")
Method 3: CLI
Index and query from the command line:
# Index documents
praisonai rag index ./documents --collection my_docs
# Query
praisonai rag query "What is the main finding?" --collection my_docs
# Interactive chat
praisonai rag chat --collection my_docs
Streaming Responses
For real-time output:
from praisonaiagents import Knowledge, RAG
knowledge = Knowledge()
knowledge.add("large_document.pdf")
rag = RAG(knowledge=knowledge)
# Stream the response
for chunk in rag.stream("Summarize the document"):
print(chunk, end="", flush=True)
Configuration Options
from praisonaiagents import RAGConfig
config = RAGConfig(
top_k=5, # Number of chunks to retrieve
min_score=0.5, # Minimum relevance score
max_context_tokens=4000, # Context size limit
include_citations=True, # Include source citations
rerank=False, # Enable reranking (optional)
)
Multi-Agent Shared Knowledge
Multiple agents can share the same knowledge base:
from praisonaiagents import Agent, Knowledge, AgentTeam
# Shared knowledge base
shared_kb = Knowledge()
shared_kb.add("company_docs/")
# Multiple agents using same knowledge
researcher = Agent(
name="Researcher",
knowledge=shared_kb,
)
writer = Agent(
name="Writer",
knowledge=shared_kb,
)
# Run together
agents = AgentTeam(agents=[researcher, writer])
Next Steps