SuperAPI AI 工具集

adding-memory

智能体与模型

查看项目

更新于 10-16 02:17

技能介绍

用途

adding-memory 用于向 OpenViking(简称 ov)添加强持久记忆,把文本和结构化对话转化为可搜索、可检索的记忆,存入 OpenViking 的上下文数据库。适合在以下情况使用:

  • 学到值得跨会话记住的信息之后
  • 需要持久化对话中的见解、决策或发现时
  • 希望从交互中逐步构建知识库时
  • 智能体想存储上下文以供未来检索时

主要能力

该工具通过 ov add-memory 命令写入记忆。它提供两种输入模式,可在纯文本与多轮模式之间按需选择。多轮模式可以包含更复杂的见解,并交由 OpenViking 处理记忆抽取。

模式一:纯文本(压缩记忆)

将一段简单字符串作为用户消息存储:

ov add-memory "User's name is Bob, he participate in Global Hackathon in 2025-01-08, and won Champion."

模式二:多轮对话(更丰富的上下文)

传入由 {role, content} 对象组成的 JSON 数组,以存储完整交流:

ov add-memory '[
  {"role": "user", "content": "I love traveling. Give me some options of Transport from Beijing to Shanghai."},
  {"role": "assistant", "content": "You can use train, bus, or plane. Train is the fastest, but you need to book in advance. Bus is cheaper, but you need to wait. Plane is the most expensive, but you can get there any time of day."},
  {"role": "user", "content": "I prefer train. I like sightseeing on the train. Can you give me the train schedule?"},
  < ... more possible conversation about schedule and tickest need to be memorized ... >
]'

输出

命令返回抽取到的记忆数量:

memories_extracted   1

智能体最佳实践

如何写出好的记忆

  • 具体明确——包含具体细节,而非模糊概括
  • 包含上下文——说明为什么重要、何时适用
  • 使用结构化格式——把“是什么”与“为什么”分开

批量处理相关事实

将相关记忆归入一次调用,而不是拆成许多小调用:

ov add-memory '[
  {"role": "user", "content": "Key facts about the ov_cli Rust crate"},
  {"role": "assistant", "content": "1. runs faster than python cli\n2. uses HttpClient to connect openviking server\n3. Output formatting supports table and JSON modes\n4. Config lives at ~/.openviking/ovcli.conf"}
]'

前置条件

  • CLI 已完成配置:~/.openviking/ovcli.conf

适用场景与限制

该工具适用于需要在会话之间保留记忆、沉淀知识库的智能体与聊天场景,尤其适合存放用户偏好、关键事实与决策记录。使用前需保证 OpenViking CLI 已正确配置。关于平台支持范围、收费方式、具体存储容量或检索效果等细节,暂未提供。