参数
namestring必填小写、数字和连字符,最多为64。 其它任何文件都转换为文件;不能拒绝的文件。
contentstring必填便条本身, 最多有4,000个字符。 空的已被拒绝 。
descriptionstring一条线,最多200。这就是代理商在选择时所看到的——见 下 数.
typestringpreference · project · fact · correction · other。未知值变为 other.
sourcestringuser 或 agent。任何非 user 成为 agent.
sessionIdstring本届会议是在有一次研讨会时学到的。
姓名是身份
保存时保存的名称已经存在, 取代了该注。 这是整个更新机制, 这就是为什么这个名称值得选择 : 这是以后您必须匹配的东西 。
await api.memory.save({ name: "tone-of-voice", content: "Short answers.", source: "user" });
await api.memory.save({ name: "tone-of-voice", content: "Short answers, in French.", source: "user" });
// One note. The second content replaced the first.api.memory.save(name="tone-of-voice", content="Short answers.", source="user")
api.memory.save(name="tone-of-voice", content="Short answers, in French.", source="user")
# One note. The second content replaced the first.| 你过 | 存储为 |
|---|---|
| 声音音音音音音音音 | 声音音调 |
| user_preferences | 用户首选项 |
| 下水! 下水! | d- 就业 |
| ! ! ! | 被拒绝 - invalid_name |
有两个不同的名称可以在一个上相交, 第二个保存后不说替换第一个注。 选择平坦、 稳定的名称, 并从用户输入中读回您创建时所返回的名称 。
写入代理的描述
只有当注注的内容看起来相关时,才打开内容,而相关性仅根据描述来判断。所以描述应该说 此时,这经文值得读读而不是它所包含的东西
| 描述不严 | 更好 |
|---|---|
| “首选” | ”这个用户如何想被写到 |
| 数据库 | “使用哪个数据库, 以及永远别碰哪个数据库?” |
| “关于该项目的说明 ” | “该项目的部署规则,包括禁止的内容” |
返回值
const note = await api.memory.save({
name: "deploy-rules",
description: "The deploy rules for this project, including what is forbidden",
content: "No deploys on Friday. Staging first, always. Migrations run separately.",
type: "project",
source: "user",
});
note.name; // "deploy-rules"
note.type; // "project"
note.updatedAt;note = api.memory.save(
name="deploy-rules",
description="The deploy rules for this project, including what is forbidden",
content="No deploys on Friday. Staging first, always. Migrations run separately.",
type="project",
source="user",
)
note["name"] # "deploy-rules"
note["type"] # "project"
note["updatedAt"]保存的便条—— 在名称被转换后, 文本被剪短到它的极限。 读回去, 而不是假设你发送的东西是保存的 。
错误
| 代码 | 状态 | 触发条件 |
|---|---|---|
| invalid_name | 400 | 转换后,没有留下任何有用的东西。 |
| content_required | 400 | 内容为空或仅是空白空格 。 |
| too_many_memories | 400 | 已经200便士了,这将是一个新的。 |
too_many_memories 仅适用于 新 注意: 替换一个现有的顶部工作, 因为它没有增加任何内容。 这是故意的, 满满不应该阻止你纠正错误。
import { IaGenifyError } from "iagenify";
try {
await api.memory.save({ name, content, description, type, source: "user" });
} catch (err) {
if (err instanceof IaGenifyError && err.code === "too_many_memories") {
// Let the user choose what goes. Do not evict on their behalf.
return { needsPruning: await api.memory.list() };
}
throw err;
}from iagenify import IaGenifyError
try:
api.memory.save(name=name, content=content, description=description, type=kind, source="user")
except IaGenifyError as error:
if error.code != "too_many_memories":
raise
# Let the user choose what goes. Do not evict on their behalf.
needs_pruning = api.memory.list()源代码, 以及为什么它值得设置
任何非 "user" 记录为 agent诚实地说,这是让一个界面分开的东西,你告诉我这个,从我研究出来的“我研究出来的”——第二个值得更容易地质疑。