Knowledge Overview
Give your agents access to documents and data
Knowledge Overview
Knowledge allows your agents to answer questions using your own documents – PDFs, text files, web pages, and more.
How It Works
- Add documents → Chunked and indexed
- Ask questions → Agent retrieves relevant context
- Get answers → With source citations
Quick Start
from praisonaiagents import Agent
agent = Agent(
name="Research Assistant",
knowledge=["research.pdf", "docs/"]
)
response = agent.start("What are the key findings?")That’s it! The agent can now answer questions using your documents.
When to Use
| Approach | Best For | Link |
|---|---|---|
Agent(knowledge=[...]) | Most use cases | Quick Start → |
Knowledge() class | Custom indexing | Knowledge API → |
RAG() class | Custom pipelines | RAG Module → |
Knowledge vs Memory vs RAG
| Feature | Knowledge | Memory | RAG |
|---|---|---|---|
| Purpose | Answer from documents | Remember conversations | Retrieve + Generate |
| Data Source | Files, URLs | Conversations | Knowledge base |
| Updates | Manual (re-index) | Automatic | Uses Knowledge |
| Best For | Q&A, research | Chat continuity | Citations, search |
What Knowledge.search() returns
Knowledge.search() returns a typed SearchResult from praisonaiagents.knowledge.models.
| Field | Type | Description |
|---|---|---|
results | list[SearchResultItem] | Ranked items |
metadata | dict | Search-level metadata (always dict, never None) |
query | str | Original query string |
total_count | int | Total available (may exceed len(results) if paginated) |
from praisonaiagents import Agent
from praisonaiagents.knowledge import Knowledge
knowledge = Knowledge()
knowledge.store("Paris is the capital of France.")
results = knowledge.search("capital of France", user_id="alice")
for item in results.results:
print(f"[{item.score:.2f}] {item.text} ({item.source or '-'})")