api.memory

list()

api.memory.list({ limit }) → Promise<Memory[]>

Ogni nota del conto, cambiata prima, ultimamente, con il suo contenuto. Questo è l'ecran que mostra l'usuario.

GET /api/ai/memoriesfreean array
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Parâmetros

limitinteger

Quanti. Predefinit a 200, che è anche il cap e il maximum un conto può tenir.

Dando il cap e il maximum sono il mesmo numero, il predefinit restitue tutto. Non c'è pagination, perché non c'è nulla da paginare.

Retorno

[
  {
    id: "…",
    name: "tone-of-voice",
    description: "How this user wants to be written to",
    content: "Prefers short, direct answers in French.",
    type: "preference",
    source: "user",
    createdAt: "…",
    updatedAt: "…"
  }
]
[
    {
        "id": "…",
        "name": "tone-of-voice",
        "description": "How this user wants to be written to",
        "content": "Prefers short, direct answers in French.",
        "type": "preference",
        "source": "user",
        "createdAt": "…",
        "updatedAt": "…",
    }
]

Un array, directamente — non un envelope. Un conte senza nota da un array vazio.

Il contenti viene con il

Diversamente da quello che il agente ottiene — que è solo l'indice — questo restitui tutto, contenuto incluso. É destinado a una persona che guarda a ciò che è ricordat de loro.

const notes = await api.memory.list();

for (const n of notes) {
  console.log(`${n.name} · ${n.type} · by ${n.source}`);
  console.log(`  ${n.description}`);
  console.log(`  ${n.content}`);
}
notes = api.memory.list()

for n in notes:
    print(f"{n['name']} · {n['type']} · by {n['source']}")
    print(f"  {n['description']}")
    print(f"  {n['content']}")

Agrupamento per tipo

tipoSignificado
PreferitComo l'usuariu vor che le cose fa.
progettoAlgo sul lavoro in mano.
istuAlgo stabil e verificabile.
CorrezioneAlgo che l'agente s'erra e che si dice.
otreIl predefinit quando ningun altro cadde.
const byType = new Map();
for (const n of await api.memory.list()) {
  byType.set(n.type, [...(byType.get(n.type) || []), n]);
}

// Corrections are the ones worth reviewing: each is something that went wrong once.
byType.get("correction")?.forEach((n) => console.log(n.name, "·", n.content));
from collections import defaultdict

by_type = defaultdict(list)
for n in api.memory.list():
    by_type[n["type"]].append(n)

# Corrections are the ones worth reviewing: each is something that went wrong once.
for n in by_type["correction"]:
    print(n["name"], "·", n["content"])

Un rivisuo vale la pena di run

Memoria decae in utilit in lugar de in talla: una nota scritta a proposito di un progetto che termina è ancora led in contexto ogni vez. Guardando a ciò che non ha cambiat in un tempo longo è la versione barata de poda.

const notes = await api.memory.list();
const quarter = Date.now() - 90 * 24 * 60 * 60 * 1000;

const old = notes.filter((n) => Date.parse(n.updatedAt) < quarter && n.type === "project");

for (const n of old) {
  console.log(`still remembered, last touched ${n.updatedAt}: ${n.name} — ${n.description}`);
}
from datetime import datetime, timedelta, timezone

notes = api.memory.list()
quarter = datetime.now(timezone.utc) - timedelta(days=90)

old = [n for n in notes
       if n["type"] == "project" and datetime.fromisoformat(n["updatedAt"].replace("Z", "+00:00")) < quarter]

for n in old:
    print(f"still remembered, last touched {n['updatedAt']}: {n['name']} — {n['description']}")
Prune a mano, o lascia l'usuario lo fa

Una nota è circa il titulari del conto, quindi cancellare uno in nome di loro è una decisione, non pulizies. Mostrando-le la lista è generalmente la mossa migliore.