TencentDB Agent Memory批量导入工具:如何快速迁移历史对话数据?
2026/8/7 19:06:07 网站建设 项目流程

TencentDB Agent Memory批量导入工具:如何快速迁移历史对话数据?

【免费下载链接】TencentDB-Agent-MemoryTencentDB Agent Memory is a team-level memory hub for AI Agents — turning conversations, docs, and code into four reusable memory assets (Chat Memory, Skill, LLM-Wiki, Code-Graph) that are governed, shared, and equipped across agents and frameworks.项目地址: https://gitcode.com/GitHub_Trending/te/TencentDB-Agent-Memory

TencentDB Agent Memory是一款团队级AI Agent记忆中枢,能够将对话、文档和代码转化为四种可复用的记忆资产(聊天记忆、技能、LLM知识库、代码图谱),实现跨Agent和框架的治理、共享与装备。本文将详细介绍如何使用其批量导入工具快速迁移历史对话数据,帮助你轻松完成数据迁移工作。

为什么需要批量迁移历史对话数据?

在AI Agent的应用过程中,历史对话数据是非常宝贵的资源。这些数据包含了用户的偏好、需求以及Agent的交互模式等重要信息。将历史对话数据迁移到TencentDB Agent Memory中,能够让AI Agent更好地理解用户,提供更加个性化、精准的服务。

随着数据量的不断增长,手动迁移历史对话数据变得效率低下且容易出错。TencentDB Agent Memory提供的批量导入工具,能够帮助用户快速、准确地完成历史对话数据的迁移,节省大量时间和精力。

认识TencentDB Agent Memory的记忆层次

TencentDB Agent Memory采用了分层的记忆结构,将记忆分为L0原始日志、L1原子记忆、L2场景块和L3角色画像四个层次。这种分层结构能够有效地组织和管理记忆数据,提高记忆的检索和利用效率。

  • L0原始日志(Raw Log):全面保留原始对话和事件流,确保原始信息不丢失,为数据提供依据。
  • L1原子记忆(Atomic Memory):自动提取事实、偏好、约束和状态,从繁杂的语音中稳定提取关键信息。
  • L2场景块(Scene Block):按项目、主题或工作流场景进行聚类,结合上下文召回,减少跨场景误用。
  • L3角色画像(Persona):稳定的用户偏好与服务方式画像,让Agent按照用户习惯协作。

批量迁移工具:SQLite → 腾讯云向量数据库迁移工具

TencentDB Agent Memory提供了一款离线迁移工具,用于将memory-tdai的数据从本地SQLite存储迁移到腾讯云向量数据库(TCVDB)。该工具位于项目的scripts/migrate-sqlite-to-tcvdb/目录下,主要文件包括cli-entry.ts(CLI入口)、sqlite-to-tcvdb.ts(迁移核心逻辑)、config-write.ts(OpenClaw配置更新)和manifest-write.ts(Manifest重写)等。

前置条件

在使用迁移工具之前,需要确保满足以下条件:

  • Node.js >= 22.16.0
  • 插件已通过openclaw plugins install安装
  • 迁移脚本已编译

编译迁移脚本

迁移脚本使用TypeScript编写,运行前需要先进行编译。打开终端,进入项目根目录,执行以下命令:

npm run build:migrate-sqlite-to-vdb

编译产物将输出到scripts/migrate-sqlite-to-tcvdb/dist/目录下,可直接用Node运行。

迁移步骤

1. 预检模式(可选)

在正式迁移之前,可以先使用预检模式查看源数据,确保数据准备无误。执行以下命令:

npm run migrate:sqlite-to-tcvdb -- \ --plugin-data-dir ~/.openclaw/memory-tdai \ --openclaw-config-path ~/.openclaw/openclaw.json \ --tcvdb-url http://127.0.0.1:80 \ --tcvdb-username root \ --tcvdb-api-key-env TCVDB_API_KEY \ --tcvdb-database agent_memory_prod \ --tcvdb-embedding-model bge-large-zh \ --dry-run
2. 正式迁移

预检无误后,执行正式迁移命令:

npm run migrate:sqlite-to-tcvdb -- \ --plugin-data-dir ~/.openclaw/memory-tdai \ --openclaw-config-path ~/.openclaw/openclaw.json \ --tcvdb-url http://127.0.0.1:80 \ --tcvdb-username root \ --tcvdb-api-key-env TCVDB_API_KEY \ --tcvdb-database agent_memory_prod \ --tcvdb-embedding-model bge-large-zh \ --yes

常用参数说明

参数必填默认值说明
--plugin-data-dir插件数据目录路径
--openclaw-config-pathopenclaw.json配置文件路径
--sqlite-path<plugin-data-dir>/vectors.dbSQLite数据库文件路径
--tcvdb-urlTCVDB服务地址
--tcvdb-usernameTCVDB用户名
--tcvdb-api-key*TCVDB API密钥(明文)
--tcvdb-api-key-env*包含API密钥的环境变量名
--tcvdb-databaseTCVDB数据库名
--tcvdb-embedding-modelEmbedding模型名称
--layersl0,l1,l2,l3要迁移的层(逗号分隔)
--dry-runfalse仅预览,不执行写入
--yesfalse跳过交互确认

注意--tcvdb-api-key--tcvdb-api-key-env二选一,必须提供其中一个。

高级迁移场景

1. 指定自定义SQLite路径

当数据库不在默认vectors.db位置时,可以通过--sqlite-path参数指定自定义路径:

npm run migrate:sqlite-to-tcvdb -- \ --plugin-data-dir ~/.openclaw/memory-tdai \ --sqlite-path /backup/2026-04/vectors-snapshot.db \ --openclaw-config-path ~/.openclaw/openclaw.json \ --tcvdb-url http://127.0.0.1:80 \ --tcvdb-username root \ --tcvdb-api-key-env TCVDB_API_KEY \ --tcvdb-database agent_memory_prod \ --tcvdb-embedding-model bge-large-zh \ --yes
2. 迁移指定记忆层

如果只需要迁移部分记忆层,可以使用--layers参数指定:

# 只迁移L1记忆层 npm run migrate:sqlite-to-tcvdb -- \ --plugin-data-dir ~/.openclaw/memory-tdai \ --openclaw-config-path ~/.openclaw/openclaw.json \ --tcvdb-url http://127.0.0.1:80 \ --tcvdb-username root \ --tcvdb-api-key-env TCVDB_API_KEY \ --tcvdb-database agent_memory_prod \ --tcvdb-embedding-model bge-large-zh \ --layers l1 \ --yes
3. 英文语料场景

对于英文语料,可以使用英文BM25分词:

npm run migrate:sqlite-to-tcvdb -- \ --plugin-data-dir ~/.openclaw/memory-tdai \ --openclaw-config-path ~/.openclaw/openclaw.json \ --tcvdb-url http://127.0.0.1:80 \ --tcvdb-username root \ --tcvdb-api-key-env TCVDB_API_KEY \ --tcvdb-database agent_memory_prod \ --tcvdb-embedding-model bge-large-en-v1.5 \ --bm25-language en \ --yes

总结

TencentDB Agent Memory的批量导入工具为历史对话数据的迁移提供了便捷、高效的解决方案。通过本文的介绍,你已经了解了迁移工具的基本使用方法、参数说明以及高级迁移场景。希望这些内容能够帮助你顺利完成历史对话数据的迁移工作,充分利用TencentDB Agent Memory的强大功能,提升AI Agent的服务质量和效率。

如果你在使用过程中遇到任何问题,可以查阅项目中的官方文档或相关源码获取更多帮助。迁移工具的源码位于scripts/migrate-sqlite-to-tcvdb/目录下,你可以通过阅读源码深入了解迁移的实现细节。

现在,就开始使用TencentDB Agent Memory批量导入工具,让你的历史对话数据发挥更大的价值吧!

【免费下载链接】TencentDB-Agent-MemoryTencentDB Agent Memory is a team-level memory hub for AI Agents — turning conversations, docs, and code into four reusable memory assets (Chat Memory, Skill, LLM-Wiki, Code-Graph) that are governed, shared, and equipped across agents and frameworks.项目地址: https://gitcode.com/GitHub_Trending/te/TencentDB-Agent-Memory

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询