Skip to main content

Knowledge Overview

Knowledge allows your agents to answer questions using your own documents - PDFs, text files, web pages, and more.

How It Works

  1. Add documents → Chunked and indexed
  2. Ask questions → Agent retrieves relevant context
  3. 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

ApproachBest ForLink
Agent(knowledge=[...])Most use casesQuick Start →
Knowledge() classCustom indexingKnowledge API →
RAG() classCustom pipelinesRAG Module →

Knowledge vs Memory vs RAG

FeatureKnowledgeMemoryRAG
PurposeAnswer from documentsRemember conversationsRetrieve + Generate
Data SourceFiles, URLsConversationsKnowledge base
UpdatesManual (re-index)AutomaticUses Knowledge
Best ForQ&A, researchChat continuityCitations, search

What Knowledge.search() returns

Knowledge.search() returns a typed SearchResult from praisonaiagents.knowledge.models.
FieldTypeDescription
resultslist[SearchResultItem]Ranked items
metadatadictSearch-level metadata (always dict, never None)
querystrOriginal query string
total_countintTotal available (may exceed len(results) if paginated)
A SearchResult is a dataclass, so it is always truthy — even when empty. Check .results instead of the object.
# ❌ Wrong — SearchResult is a dataclass, always truthy
if not results:
    print("No results")

# ✅ Right — check .results (or .total_count)
if not results.results:
    print("No results")
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 '-'})")
Each SearchResultItem can be passed directly into RAG context utilities like build_context and deduplicate_chunks. See Search Results for the full field reference.

Next Steps

Quick Start

Get started in 5 minutes

Storage Options

Configure vector stores

Chat with PDFs

Build a PDF chat agent

RAG

Advanced retrieval