Knowledge Base Setup
Create and configure knowledge bases for your agents
Attach file and URL sources so agents answer from your organisation’s documents.
from praisonaiagents import Agent, Knowledge
knowledge = Knowledge(sources=["docs/", "faq.pdf"])
agent = Agent(
name="Support Agent",
instructions="Answer using the knowledge base only.",
knowledge=knowledge,
)
agent.start("What is our refund policy?")The user asks a question; the agent retrieves relevant chunks and returns a grounded answer.
Add domain-specific knowledge to your agents using knowledge bases.
Quick Start
- Simple Usage
python from praisonaiagents import Agent, Knowledge # Create knowledge base from files knowledge = Knowledge( sources=["docs/", "data.pdf", "faq.txt"] ) # Create agent with knowledge agent = Agent( name="Support Agent", instructions="Answer questions using the knowledge base.", knowledge=knowledge ) result = agent.start("What is your refund policy?") - With Configuration
python from praisonaiagents import Agent, Knowledge knowledge = Knowledge( sources=["docs/"], chunk_size=500, chunk_overlap=50, ) agent = Agent( name="Support Agent", instructions="Answer using the knowledge base.", knowledge=knowledge, ) agent.start("Summarise the onboarding guide.")
Knowledge Sources
From Files
knowledge = Knowledge(
sources=[
"documents/", # Directory
"manual.pdf", # PDF
"faq.md", # Markdown
"data.csv" # CSV
]
)From URLs
knowledge = Knowledge(
sources=[
"https://docs.example.com/api",
"https://example.com/faq"
]
)From Text
knowledge = Knowledge(
sources=[],
texts=[
"Company policy: All refunds within 30 days.",
"Support hours: 9 AM - 5 PM EST"
]
)Configuration
knowledge = Knowledge(
sources=["docs/"],
chunk_size=500, # Characters per chunk
chunk_overlap=50, # Overlap between chunks
embedding_model="text-embedding-3-small",
vector_store="chroma", # or "faiss", "qdrant"
top_k=5 # Results to retrieve
)