Knowledge Source Types
What Agent(knowledge=…) accepts today — file paths, plain text, and cloud storage URIs
Agent(knowledge=...) accepts local file paths (any UTF-8 text file), plain text, and cloud storage URIs (s3://, gs://, az://, Azure Blob HTTPS) — arbitrary web URLs are not ingested and are skipped with a warning.
from praisonaiagents import Agent
agent = Agent(
name="Reader",
instructions="Answer from the provided notes.",
knowledge=["notes.pdf", "Key fact: launch is in March."],
)
agent.start("When is the launch?")graph TB
subgraph "Knowledge routing (per source in Agent(knowledge=[...]))"
In[📥 Input string] --> IsCloud{Cloud URI?<br/>s3:// gs:// az://<br/>or Azure blob URL}
IsCloud -->|Yes| Cloud[☁️ Download & re-enter]
IsCloud -->|No| IsURL{http:// or<br/>https://?}
IsURL -->|Yes| Skip[⚠️ Warn & skip]
IsURL -->|No| KnownExt{Extension in<br/>.pdf .doc .docx .txt<br/>.md .csv .json .xml<br/>.html or media/zip?}
KnownExt -->|Yes| Handler[📖 Dedicated handler]
KnownExt -->|No| Exists{Path exists<br/>on disk?}
Exists -->|Yes, UTF-8 text| ReadText[📄 Read + chunk as text<br/>metadata: file_type, filename]
Exists -->|Yes, binary| Raise1[🚨 ValueError:<br/>Cannot read as UTF-8]
Exists -->|No| RawText[📝 Store as raw text]
Cloud --> Handler
Handler --> Store[(🗃️ Vector store)]
ReadText --> Store
RawText --> Store
end
classDef in fill:#6366F1,stroke:#7C90A0,color:#fff
classDef decision fill:#F59E0B,stroke:#7C90A0,color:#fff
classDef process fill:#189AB4,stroke:#7C90A0,color:#fff
classDef warn fill:#8B0000,stroke:#7C90A0,color:#fff
classDef store fill:#10B981,stroke:#7C90A0,color:#fff
class In in
class IsCloud,IsURL,KnownExt,Exists decision
class Cloud,Handler,ReadText,RawText process
class Skip,Raise1 warn
class Store storeWhat Each Source Does
_process_knowledge inspects every item and routes it by type.
| Source | Example | Behaviour |
|---|---|---|
| Known-extension file | "notes.pdf" | Dedicated handler (.pdf .doc .docx .txt .md .csv .json .xml .html, media, .zip) — read and indexed |
| Other existing file | "src/auth.py", "Dockerfile" | Read as UTF-8 and chunked — metadata records file_type and filename. Since PraisonAI PR #4788. |
| Plain string (not a path) | "Key fact: ..." | Knowledge.store(text) — stored as text |
| Cloud URI | "s3://bucket/handbook.pdf", "gs://…", "az://…", Azure blob URL | Downloaded to temp, indexed with the same reader as local files. Original URI preserved in metadata. See Cloud Sources. |
| Web URL | "https://example.com" | Warns and skips — not ingested |
Indexing Source and Text Together
Mix source files, documents, suffix-less files, and raw strings in one list.
from praisonaiagents import Agent
agent = Agent(
name="Codebase Assistant",
instructions="Answer from the indexed files.",
knowledge=[
"src/auth.py", # source file: read as UTF-8
"docs/architecture.md", # markdown: dedicated handler
"Dockerfile", # suffix-less: read as UTF-8
"Key fact: launch is in March", # raw string: stored as text
],
)
agent.start("Summarise how auth is set up.")Fetch, Then Pass Text
Fetch the page yourself and pass the text as a knowledge source.
import requests
from praisonaiagents import Agent
text = requests.get("https://example.com/article").text
agent = Agent(name="Reader", instructions="Summarise the article.", knowledge=[text])
agent.start("Summarise it.")Best Practices
Convert web content to text before ingesting
Fetch pages with requests, httpx, or a scraper, then pass the extracted text as a knowledge string.
Prefer local files for documents
Save PDFs and docs locally and pass the path — Knowledge.add(path) reads and chunks them for you.
Check logs if a source seems missing
A skipped URL logs a warning; if answers lack a source you expected, confirm it was a file or text, not a URL.