Where did you hear about us?
1 of 6
Memory tools

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 work
const tools = mem.memoryTools("jimin", { preset: "S-2", speakers: true, dates: true });
const system = "You are Kai, Jimin's assistant.\n\n" + tools.note;   // stays the same: it caches
const context = await 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 await tools.run(call).
await mem.addTurn(message, reply, "jimin", { workId: tools.workId });   // closes this turn's work
let tools = mem.memory_tools_preset("jimin", None, "S-2")?
    .with_speakers(true)
    .with_dates(true);
let system = format!("You are Kai, Jimin's assistant.\n\n{}", tools.note());   // stays the same: it caches
let context = tools.begin(&message).await?;                                     // what comes to mind, numbered
// Call your model with system, context and tools.definitions(ToolFormat::Anthropic),
// and answer each tool call it makes with tools.run(&call).await.
mem.add_turn_opts(&message, &reply, "jimin", &WriteOpts {
    work_id: tools.work_id(), ..Default::default()                          // closes this turn's work
}).await?;

The tools

  • memory_deeper looks further with the same question.
  • memory_around shows what was said around one memory.
  • memory_search looks again with another question the model writes.

Turned on when you ask

Each is off by default.

  • speakers puts who said it on every line: you for the assistant's own lines, a name for anyone else.
  • dates adds memory_timeline: the memories held, in the order they happened, with their dates.
  • images brings up to three photos a look and adds memory_photo, which shows a photo to the model.
  • sleep puts the files a sleep wrote (the core and the boxes' names) in the note and adds open_box. After a sleep, load() reads them again.
  • seen adds memory_recent, the recent conversation, newest first, and memory_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.