Save a fact
The name
Persistent memory lets an agent remember facts even after a script exits. Calling add_long_term saves a concise sentence into your local memory store so future queries can search and retrieve it by keyword.
add_long_term writes one sentence into the file for this learner.
The result is the sentence that was saved. Nothing else is stored.
Example
from praisonai.memory import FileMemory
memory = FileMemory(user_id="learner")
memory.add_long_term("The learner name is Nila.")
found = memory.search("Nila")
print(found[0]["item"]["content"])Example explained
- FileMemory — The file that keeps facts. user_id is whose file it is.
- add_long_term — The sentence to keep.
Second fact
Store a second sentence and search by a different keyword.
Expected output: the saved sentence prints back cleanly when queried, proving only the intended fact was stored.
Example
from praisonai.memory import FileMemory
memory = FileMemory(user_id="learner")
memory.add_long_term("The learner name is Nila.")
memory.add_long_term("The learner timezone is IST.")
print(memory.search("timezone")[0]["item"]["content"])Example explained
- from praisonai.memory import FileMemory — Imports FileMemory needed for second fact.
- Memory store — Persists facts on disk so later turns or runs can recall them.
Reference: documentation