Knowledge
Note: If the sandbox prints a parser warning, the preview reply underneath is still the result of the run.
Save a note
Knowledge is a note the agent can read. These lines save one sentence and point the agent at that file.
write_text saves the sentence. knowledge is that file. Run prints the sentence. Searching it on your computer is the same line, and it is covered in the docs.
Example
from pathlib import Path
from praisonai import Agent
notes = Path("/tmp/praison-notes.txt")
notes.write_text("PraisonAI agents can read a note you saved.")
agent = Agent(
name="Knowledge Agent",
instructions="You answer questions based on the provided knowledge.",
knowledge=[str(notes)],
)
print(notes.read_text())Example explained
- knowledge — A list of files. This example writes one, then reads it.
Answer only from the note
Before files on disk, practise grounding: the note is in the prompt; the agent must not invent.
Example
from praisonai import Agent
note = "Refund window is 14 days."
agent = Agent(
instructions="Answer using only the Note line. Say unknown if Note does not apply.",
)
print(agent.start(f"Can I refund after 30 days?\nNote: {note}"))Example explained
- from praisonai import Agent — Imports Agent needed for answer only from the note.
- Agent(…) — Instantiates the Agent configured for answer only from the note.
- .start(…) — Executes the configured run for answer only from the note and returns the result.
Reference: documentation