Where did you hear about us?
1 of 6
기억 도구

기억 도구 - 모델이 찾기.

앱의 모델이 스스로 기억을 뒤져 보게 하는 도구 묶음입니다.

한 턴

턴마다 begin(질문)이 떠오르는 기억을 번호와 함께 텍스트로 줍니다. 모델은 그 번호를 보고 도구로 더 찾아보고, run(호출)이 도구 호출 하나하나에 답합니다. 안내문(note)과 도구 정의는 프롬프트에서 바뀌지 않는 부분에 넣습니다. 그래야 캐시가 됩니다. 도구 정의는 Anthropic 형식과 OpenAI 형식으로 받을 수 있습니다. 프리셋 S-2가 안내문, 도구 정의, 도구가 쓰는 모델을 한 번에 정합니다.

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?;

도구

  • memory_deeper 같은 질문으로 더 깊이 찾습니다.
  • memory_around 한 기억의 앞뒤에서 한 말을 봅니다.
  • memory_search 모델이 쓴 다른 질문으로 다시 찾습니다.

켜서 더하는 것

기본은 모두 꺼져 있습니다.

  • speakers 줄마다 누가 말했는지 붙입니다. 어시스턴트의 줄은 you, 다른 사람은 이름입니다.
  • dates memory_timeline 도구를 더합니다. 가진 기억을 일어난 순서대로 날짜와 함께 보여 줍니다.
  • images 한 번에 사진을 세 장까지 가져오고, memory_photo 도구로 사진을 모델에 보여 줍니다.
  • sleep 잠이 쓴 파일(핵심과 상자 이름)을 안내문에 넣고 open_box 도구를 더합니다. 잠을 잔 뒤에는 load()로 다시 읽습니다.
  • seen memory_recent(최근 대화, 최근 것부터)와 memory_seen(그 줄이 말해질 때 쥐고 있던 기억의 지금 상태)을 더합니다.

답 저장

모델의 답을 add_turn(..., work_id=tools.work_id)로 저장하면 이번 턴에 연 작업이 닫힙니다.