# list()

Canonical URL: https://developers.iagenify.com/zh/sdk/ref/memory/list/
Language: zh

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

账户上的每个便条, 最近先更改了内容 。 这是您显示用户的屏幕 。

Status: GET /api/ai/memories · free · an array

## 参数 {#parameters}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `limit` | integer |  | 多少个。 默认值 `200`,这也是账户可以持有的上限和上限。 |

由于上限和上限是同数,默认返回所有信息。没有页数,因为没有页数。

## 返回值 {#returns}

```javascript
[
  {
    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: "…"
  }
]
```

直截了当的数组,而不是信封。一个没有注释的账户给出空数组。

## 内容随内容而来 {#content}

与代理人获得什么不同——仅是索引——这就代表了一切,包括内容,而是指一个人看人们所记得的。

```javascript
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}`);
}
```

## 按类型分组 {#group}

| 类型类型类型 | 含义 |
| --- | --- |
| 优先 | 用户希望如何完成 |
| 项目 项目项目项目 | 有关手头的工作 |
| 事实事实 | 稳定且可核查的东西 |
| 更正更正 | 探员出了点问题 被告诉了 |
| 其他 | 其它东西都不符合时的默认 。 |

```javascript
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));
```

## 值得审查的正在运行 {#review}

内存的功用衰减, 大小衰减: 有关结束的项目的注释仍然被读入上下文。 观察一下长期没有变化的是廉价的修剪版本 。

```javascript
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}`);
}
```

> **手工或让用户自己动手**
>
> 便条是关于账户持有人的, 所以删除代表账户持有人的便条是决定, 不是内部管理。 向他们展示列表通常比较好 。

- [save()](/zh/sdk/ref/memory/save): 写作或替换一个。
- [delete()](/zh/sdk/ref/memory/delete): 正在删除一个名字 。

```python
[
    {
        "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": "…",
    }
]
```

```python
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']}")
```

```python
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"])
```

```python
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']}")
```
