Memory

Memory is a fact you choose to keep about a person. RAG is a note you search. This course saves a name, recalls it, and refuses to store a password.

The fact can be kept in a file, or in SQLite, Chroma, mem0, or MongoDB. These pages use the file. The last page also saves the name in SQLite. Chroma, mem0, and MongoDB are shown without a Try it button. The Agents lesson called Memory is a different, shorter idea: one task seeing the previous task.

A fact from an empty chat

Nothing was said before this run. The fact is written, then found by one word. Press Try it Yourself, then Run. The result is: The learner's favourite tea is cardamom.

Example

from praisonaiagents.memory import FileMemory

memory = FileMemory(user_id="learner")
memory.add_long_term("The learner's favourite tea is cardamom.")
print(memory.search("tea")[0]["item"]["content"])

Try it Yourself

Example explained

  • add_long_term — Writes one fact into the learner’s file.
  • search — Finds that fact from the word tea.

Next

Exercises · Quiz · Reference