Tools for the model.
Tools that let your app's model look through its memory by itself.
Each turn
Each turn, begin(question) gives what comes to mind, numbered, as text for the prompt. The model looks further with the tools, and run(call) answers each tool call. Put the note (note) and the tool definitions in the part of the prompt that stays the same, so they cache. The definitions come in Anthropic's format or OpenAI's. The preset S-2 sets the note, the definitions and the model the tools call, together.
tools = mem.memory_tools("jimin", preset="S-2", speakers=True, dates=True)
system = "You are Kai, Jimin's assistant.\n\n" + tools.note # stays the same: it caches
context = tools.begin(message) # what comes to mind, numbered
# Call your model with system, context and tools=tools.definitions("anthropic"),
# and answer each tool call it makes with tools.run(call).
mem.add_turn(message, reply, "jimin", work_id=tools.work_id) # closes this turn's workThe tools
memory_deeperlooks further with the same question.memory_aroundshows what was said around one memory.memory_searchlooks again with another question the model writes.
Turned on when you ask
Each is off by default.
speakersputs who said it on every line:youfor the assistant's own lines, a name for anyone else.datesaddsmemory_timeline: the memories held, in the order they happened, with their dates.imagesbrings up to three photos a look and addsmemory_photo, which shows a photo to the model.sleepputs the files a sleep wrote (the core and the boxes' names) in the note and addsopen_box. After a sleep,load()reads them again.seenaddsmemory_recent, the recent conversation, newest first, andmemory_seen, the memories one of its lines had in hand, as they stand now.
Keeping the answer
Store the model's answer with add_turn(..., work_id=tools.work_id), and the work this turn opened closes.