尧图网站设计 尧图网站设计YAOTU DESIGN
ARTICLE DETAIL

资讯详情

深耕网站设计与一线实操的经验洞察。

Supermemory 连接器如何手动触发重新同步

Supermemory 连接器如何手动触发重新同步 Supermemory 连接器如何手动触发重新同步【免费下载链接】supermemoryMemory and context engine app that is extremely fast, scalable, and can be run fully locally. The Memory API for the AI era.项目地址: https://gitcode.com/GitHub_Trending/su/supermemorySupermemory 的连接器Notion、Google Drive、Gmail、OneDrive、GitHub、Granola、Web Crawler 等在建立连接后会自动运行部分提供商通过 webhook 实时同步并叠加每 4 小时的定时同步。但有些情况需要主动介入——实时同步没生效、文档卡在queued或extracting状态超过 30 分钟、或者你刚在 Notion 里新增了页面想立刻入库。这时就可以调用 import 接口手动触发一次重新同步manual sync / on-demand sync。本文的适用前提你已经拥有 Supermemory API Key下文环境变量SUPERMEMORY_API_KEY并且已经通过 OAuth 或凭据流程创建过对应连接。下文中出现的user-123、org-123都是文档示例里的 containerTag 值需要替换成你创建连接时实际使用的 tag这是手动同步定位连接的关键参数。手动同步支持哪些连接器根据 连接器总览 的同步机制表所有支持的连接器都提供按需手动同步Provider实时同步定时同步手动同步Google DriveWebhooks7 天过期每 4 小时支持GmailPub/Sub7 天过期每 4 小时支持NotionWebhooks每 4 小时支持OneDriveWebhooks30 天过期每 4 小时支持GitHubWebhooks每 4 小时支持Granola不支持不支持支持仅初始同步 手动触发Web Crawler不支持定时重新爬取7 天以上支持注意 Granola 是唯一的例外它没有实时和定时同步除了创建连接时的初始同步后续更新全靠手动触发见 Granola 连接器文档。触发一次手动重新同步用 SDK 触发TypeScriptimport是保留字语义SDK 里就是connections.importimport Supermemory from supermemory; const client new Supermemory({ apiKey: process.env.SUPERMEMORY_API_KEY! }); // 对该 provider 的所有连接触发同步 await client.connections.import(notion); // 只对你指定的 containerTag 下的连接触发推荐范围更明确 await client.connections.import(notion, { containerTags: [user-123] // 替换为你创建连接时用的 containerTag }); console.log(Manual sync initiated);Python 中方法名为import_带下划线避免与关键字冲突from supermemory import Supermemory import os client Supermemory(api_keyos.environ.get(SUPERMEMORY_API_KEY)) # 触发该 provider 全部连接的同步 client.connections.import_(notion) # 只触发指定 containerTag 下的连接 client.connections.import_( notion, container_tags[user-123] # 替换为你实际的 containerTag ) print(Manual sync initiated)第一个参数是 provider 名称取值与创建连接时一致notion、google-drive、gmail、onedrive、github、granola。第二个参数containerTags是数组用来把同步范围限定到某些用户/租户/项目下的连接。用 cURL 直接调接口Connections API 参考 中对应端点是POST /v3/connections/{provider}/import# 触发所有 Notion 连接 curl -X POST https://api.supermemory.ai/v3/connections/notion/import \ -H Authorization: Bearer $SUPERMEMORY_API_KEY # 只触发指定 containerTag 的连接 curl -X POST https://api.supermemory.ai/v3/connections/notion/import \ -H Authorization: Bearer $SUPERMEMORY_API_KEY \ -H Content-Type: application/json \ -d { containerTags: [user-123] } # ResponseGitHub 文档中给出的示例: # {message: Manual sync initiated, provider: github}$SUPERMEMORY_API_KEY是你的 API Key 环境变量user-123替换为你的实际 containerTag。返回的Manual sync initiated表示同步任务已发起同步本身是异步执行的不代表文档已经入库。验证同步是否完成手动同步是异步的触发后需要轮询连接和文档状态。连接器故障排查文档 给出的健康检查路径是先列出连接确认存在再列出该连接下的文档检查status。// 1. 确认连接存在 const connections await client.connections.list({ containerTags: [user-123] }); connections.forEach(conn { console.log(${conn.provider}: ${conn.email} - Connected ${conn.createdAt}); }); // 2. 列出该 provider 同步的文档及其状态 const documents await client.connections.listDocuments(notion, { containerTags: [user-123] }); // 3. 找出失败的文档 const failed documents.filter(doc doc.status failed); if (failed.length 0) { console.log(⚠️ ${failed.length} documents failed to sync); }cURL 等价操作# 列出连接 curl -X POST https://api.supermemory.ai/v3/connections/list \ -H Authorization: Bearer $SUPERMEMORY_API_KEY \ -H Content-Type: application/json \ -d {containerTags: [user-123]} # 检查文档同步状态source 过滤为某个 provider curl -X POST https://api.supermemory.ai/v3/documents/list \ -H Authorization: Bearer $SUPERMEMORY_API_KEY \ -H Content-Type: application/json \ -d {containerTags: [user-123], source: notion}以 Notion 为例Notion 连接器文档 给出的文档列表响应示例示例结果实际以你的工作区为准[ {title: Product Roadmap, type: notion_database, status: done}, {title: Meeting Notes, type: notion_page, status: done} ]文档状态出现done表示该文档已同步完成文档长期停在queued或extracting超过 30 分钟本身就是 排查文档 中建议触发手动重新同步的信号。触发前需要知道的同步边界documentLimit 上限Notion 连接创建时可设documentLimit1–10,000。全量同步按最后编辑时间从新到旧取页面取满上限即停看起来少同步的文档往往是编辑时间较旧的页面。增量同步只取上次同步后有变更的页面但同样计入同一个上限见 Notion 文档的 Document limit 一节。GitHub 的 webhook 有 10 分钟批处理延迟推送事件按批次处理变更大约 10 分钟后才会反映到 Supermemory。如果这个窗口期内你需要内容立刻可用就手动触发一次见 GitHub 连接器文档。Gmail 实时同步只监听 INBOX其他标签下的邮件只走定时/手动同步所以非 INBOX 内容想尽快更新时手动同步是正路见 Gmail 连接器文档。Gmail 计划要求存在文档不一致gmail.mdx 文首注明需要 Max plan 及以上而 Limitations 一节与 troubleshooting.mdx 写的是 Scale Plan 或 Enterprise Plan两处表述不一致以你控制台实际提示的计划要求为准。手动同步后仍然失败排查文档给出的后续判断项仅列文档中实际写到的文件超过 50MB 可能超时确认当前 OAuth 用户有权限访问这些文档确认文档类型在连接器支持范围内例如 GitHub 只同步.md、.mdx、.markdown、.txt、.rst、.adoc、.org等文本类文件。如果反复出现 permission denied 或同步中断文档给出的处理方式是删除并按正确权限重建连接、让用户重新走一遍 OAuth而不是反复触发 import。【免费下载链接】supermemoryMemory and context engine app that is extremely fast, scalable, and can be run fully locally. The Memory API for the AI era.项目地址: https://gitcode.com/GitHub_Trending/su/supermemory创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表