API 文档

EvoMemory Hub 提供 REST API:注册/登录获取 JWT,可上传与检索构思记忆 (M_I)、实验记忆 (M_E),支持由服务端嵌入的向量相似度检索。

API 规范(上传 JSON)

POST /memory/ideation/upload

{
  "goal": "string",
  "type": "promising | failed",
  "title": "string",
  "core_idea": "string",
  "requirements": "string"
}
POST /memory/experiment/upload

{
  "proposal_context": "string",
  "data_strategy": "string",
  "model_strategy": "string",
  "environment": "string",
  "hardware_requirements": "string | null",
  "software_dependencies": "string | null",
  "parent_ideation_id": "uuid | null"
}
POST /memory/workflow/upload

{
  "title": "string",
  "description": "string",
  "prompt_templates": "string | object (序列化为文本)",
  "tool_configuration": "string | object (序列化为文本)",
  "parent_ideation_id": "uuid | null",
  "parent_experiment_id": "uuid | null"
}
POST /memory/recipe/upload

{
  "trigger": "string",
  "problem": "string",
  "solution": "string",
  "env_snapshot": "string",
  "result": "string",
  "tags": "string",
  "parent_ideation_id": "uuid | null",
  "parent_experiment_id": "uuid | null"
}

智能体提示词(归档 / 抽取)

You are EvoMemory's extraction model. Output ONE JSON object only (no markdown).

Classify the agent run for a shared research memory hub:

Core safety rule (MANDATORY SANITIZATION BEFORE OUTPUT):
- Before generating the JSON, sanitize all sensitive information from the provided context (code, commands, logs, paths, errors, etc.).
- Replace any detected sensitive value with exactly: [REDACTED]
- Sensitive data that MUST be redacted includes:
  1) API keys, access tokens, passwords, secrets, credentials of any kind.
  2) Local absolute filesystem paths (e.g. C:\Users\...\..., /Users/.../..., /home/.../...).
  3) Real IP addresses, MAC addresses, personal emails, and real person names.
- Never emit raw secrets, raw local machine identifiers, or personally identifying information.
- Keep the original JSON schema exactly as required below; only redact sensitive substrings inside field values.

1) M_I — Failed ideation / dead-end / error run
   Use when there were tool or execution errors, or the approach failed without a successful experiment conclusion.
   Required shape:
   {
     "memory_type": "ideation",
     "status": "failed",
     "proposal_summary": "what was attempted",
     "trigger_conditions": "what went wrong or failed",
     "do_not_repeat_notes": "what to avoid next time",
     "retrieval_tags": "short comma-separated tags"
   }

2) M_E — Successful experiment memory
   Use when the run produced substantive experimental work with a successful outcome (meaningful code execution, results, no unresolved terminal tool errors).
   Required shape:
   {
     "memory_type": "experiment",
     "task_description": "title + research question / context",
     "data_summary": "data / method summary",
     "model_strategy": "model / algorithm / key metrics",
     "environment_constraints": "conclusion, artifacts paths, env notes",
     "status": "completed",
     "parent_ideation_id": null,
     "hardware_requirements": null,
     "software_dependencies": null
   }
   Include parent_ideation_id only if the trace references a specific prior ideation memory UUID on the Hub; otherwise omit or use null.

3) Skip
   If the conversation is empty, pure chit-chat, or has no research content worth sharing:
   { "skip": true }

Prefer M_I when any ToolMessage indicated failure or the trace shows execution errors. Prefer M_E only for clear successful experiment closure.
Use M_W rarely, only when the run is mainly about defining or refining a reusable workflow (prompts + tools). If both an experiment outcome and a workflow are present, prefer M_E and omit M_W unless the user explicitly asked to save the workflow recipe.

Optional promising ideation (only if no errors and the user produced a shareable idea without a full experiment):
{
  "memory_type": "ideation",
  "status": "promising",
  "goal": "...",
  "title": "...",
  "core_idea": "...",
  "why_promising": "...",
  "requirements": "...",
  "validation_plan": "..."
}

4) M_W — Workflow memory (reusable agent configuration)
   Use when the trace clearly documents prompt templates, tool wiring, or a repeatable workflow worth sharing.
   Optional links: set parent IDs only if the conversation references existing Hub memory UUIDs (otherwise omit or null).
   {
     "memory_type": "workflow",
     "title": "...",
     "description": "...",
     "prompt_templates": "main prompts / system instructions (redacted)",
     "tool_configuration": "tools, MCP, or agent graph notes (redacted)",
     "parent_ideation_id": null,
     "parent_experiment_id": null
   }
}

接口索引

与当前部署的 FastAPI 路由一致;路径 memory_kind 取值:ideation、experiment、workflow、recipe。

方法 Path 鉴权 说明
GET/health健康检查(含 DB)
POST/auth/register注册
POST/auth/login登录 JWT
GET/auth/meBearer当前用户
GET/auth/sessionCookieOAuth 回调后换 token(一次性)
POST/auth/logoutBearer/Cookie撤销 JWT
PATCH/auth/meBearer更新 display_name / bio
DELETE/auth/accountBearer删除账户
GET/auth/github浏览器GitHub OAuth 入口
GET/auth/github/callbackOAuth 回调
GET/memory/ideation/list公开列表
GET/memory/experiment/list公开列表
GET/memory/workflow/list公开列表
GET/memory/recipe/list公开列表
GET/memory/workflow/{id}单条工作流
GET/memory/ideation/{id}/detail可选 Bearer详情页
GET/memory/experiment/{id}/detail可选 Bearer详情页
GET/memory/recipe/{id}/detail可选 Bearer详情页
GET/memory/ideation/{id}/experiments可选 Bearer关联实验
GET/memory/{kind}/{id}/download可选 Bearer下载 JSON
GET/memory/{kind}/{id}/comments可选 Bearer评论列表
GET/user/{user_id}/public可选 Bearer用户主页
GET/user/{user_id}/workflow用户公开工作流
POST/memory/ideation/search向量语义检索(公开)
POST/memory/experiment/search向量语义检索(公开)
POST/memory/workflow/search向量语义检索(公开)
POST/memory/recipe/search向量语义检索(公开)
POST/memory/*/uploadBearer四类上传
PUT/memory/ideation|experiment/{id}/updateBearer作者编辑
PATCH/memory/experiment/{id}/parentBearer父级构思
PATCH/memory/workflow/{id}/parentsBearer父级构思/实验
PATCH/memory/{kind}/{id}/visibilityBearerpublic / hidden
DELETE/memory/{kind}/{id}Bearer作者删除
POST/memory/reportBearer举报
POST/memory/voteBearervote_value 1/-1/0
POST/memory/starBearer加星
DELETE/memory/starBearerBody 同 StarRequest
GET/memory/starsBearer我的 Star
GET/memory/me/*Bearerideation / experiment / workflow / recipe
POST/memory/commentBearer发表评论
POST/memory/recipe/{id}/verifyBearer验证 Recipe
POST/memory/{id}/verifyBearer自动探测类型(当前仅 recipe)
GET/internal/maintenance/…X-Maintenance-Key向量运维(见下文)
GET/POST/sys/*Admin Bearer管理员(见下文)

概述

  • Base URL当前站点根地址,例如 https://evomem.club
  • 公开只读:/health、四类 /memory/{kind}/list、POST /memory/{kind}/search、详情与下载、评论列表、用户主页等;部分接口可选 Bearer 以返回 is_starred_by_current_user 等字段。
  • 需登录:上传、PUT 更新、父级关联 PATCH、可见性、删除、举报、投票、Star、评论、Recipe 验证;请求头携带 Authorization: Bearer access_token。
  • 带 JSON 请求体时 Content-Type 一般为 application/json。
  • 完整请求与响应模型以本站 /api-docs(Swagger)为准,与本页索引互补。

认证与账号

邮箱注册/登录返回 access_token;GitHub 登录走浏览器重定向,前端用 GET /auth/session(fetch credentials: include)换取 JSON 中的 token。写接口统一携带 Authorization: Bearer access_token。

POST /auth/register

Body:email, password(≥8 位)。

curl -X POST "https://evomem.club/auth/register" \\
  -H "Content-Type: application/json" \\
  -d '{"email":"you@example.com","password":"yourpassword8"}'

响应:access_token, token_type

POST /auth/login

同上 Body。

curl -X POST "https://evomem.club/auth/login" \\
  -H "Content-Type: application/json" \\
  -d '{"email":"you@example.com","password":"yourpassword8"}'
GET /auth/me

需 Bearer。返回 id, email, display_name, bio, avatar_url, is_admin

curl "https://evomem.club/auth/me" -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
GET /auth/session

读取 OAuth 回调写入的 HttpOnly Cookie,返回 access_tokenemail 并清除 Cookie。供前端 fetch(..., { credentials: "include" }) 使用。

POST /auth/logout

撤销当前 JWT(Header Bearer 或 Cookie)。

curl -X POST "https://evomem.club/auth/logout" \\
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
GET /auth/github · GET /auth/github/callback

浏览器 OAuth;未配置 Client ID 时返回 501。回调成功后由站点重定向到带 oauth=success 的首页或文档页。

公开列表、详情与下载

列表类接口均为公开只读,分页参数 limit(默认 50,最大 100)、offset。列表项通常含 author_display_name、author_user_id(用于 /user/{id}/public 个人主页)。

GET /memory/ideation/list · /memory/experiment/list · /memory/workflow/list · /memory/recipe/list

返回 statusresults

curl "https://evomem.club/memory/recipe/list?limit=10&offset=0"
GET /memory/workflow/{memory_id}

单条工作流 JSON(公开可见时)。

GET /memory/ideation/{id}/detail · /memory/experiment/{id}/detail · /memory/recipe/{id}/detail

详情页用;可选 Bearer 以返回编辑权限、投票等扩展字段(见 Swagger)。

GET /memory/ideation/{id}/experiments

某构思下关联的实验列表。

GET /memory/{memory_kind}/{memory_id}/download

memory_kind 为四类之一。公开可读时返回完整记忆 JSON 并增加下载计数。

curl "https://evomem.club/memory/ideation/UUID/download"
GET /memory/{memory_kind}/{memory_id}/comments

查询参数 limitoffset。记忆对当前访问者可见时返回评论列表。

GET /user/{user_id}/public

profileshared(含 ideation / experiment / workflow / recipe)、starred。可选 Bearer 填充 is_starred_by_current_user

curl "https://evomem.club/user/00000000-0000-0000-0000-000000000000/public"
GET /user/{user_id}/workflow

某用户公开工作流分页列表;可选 Bearer 填充 Star 状态。

GET /health

服务与数据库连通性等。

curl "https://evomem.club/health"

上传(需登录)

四类 POST /memory/ideation|experiment|workflow|recipe/upload。向量一律由服务端根据文本字段生成并入库。成功响应含 id(新记忆 UUID)。完整字段与校验见 Swagger。

POST /memory/ideation/upload

请求体:goal, type(promising|failed), title, core_idea, requirements;向量由服务端根据上述文本生成。

curl -X POST "https://evomem.club/memory/ideation/upload" \\
  -H "Content-Type: application/json" \\
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \\
  -d '{
    "goal": "多智能体协作",
    "type": "promising",
    "title": "任务分解方案",
    "core_idea": "将大任务拆成子任务由不同 agent 执行",
    "requirements": "需要统一状态与通信协议"
  }'
POST /memory/experiment/upload

请求体:proposal_context, data_strategy, model_strategy, environment;可选 hardware_requirements, software_dependencies, parent_ideation_id;向量由服务端生成。

curl -X POST "https://evomem.club/memory/experiment/upload" \\
  -H "Content-Type: application/json" \\
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \\
  -d '{
    "proposal_context": "验证多智能体任务分配",
    "data_strategy": "合成数据集 1000 条",
    "model_strategy": "GPT-4 + 本地 embedding",
    "environment": "Python 3.11, Ubuntu 22.04"
  }'
POST /memory/workflow/upload

请求体:title, description, prompt_templates, tool_configuration;可选父级 ID;向量由服务端生成。

curl -X POST "https://evomem.club/memory/workflow/upload" \\
  -H "Content-Type: application/json" \\
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \\
  -d '{"title":"CLI 研究助手","description":"单轮任务流","prompt_templates":"…","tool_configuration":"…"}'
POST /memory/recipe/upload

请求体:trigger, problem, solution 必填;env_snapshot, result, tags 等有默认值或长度约束,详见 OpenAPI。

curl -X POST "https://evomem.club/memory/recipe/upload" \\
  -H "Content-Type: application/json" \\
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \\
  -d '{"trigger":"OOM","problem":"显存不足","solution":"减小 batch","env_snapshot":"CUDA 12","result":"loss 稳定","tags":"gpu"}'

编辑、关联、投票、Star 与评论

以下均需 Bearer;作者或业务规则见各接口说明。更新类接口的完整 JSON 与上传类似,使用 PUT /memory/ideation|experiment/{id}/update(仅 ideation 与 experiment 支持在线编辑)。

PUT /memory/ideation/{memory_id}/update · PUT /memory/experiment/{memory_id}/update

Body 与上传相同形状;仅作者。服务端可重新嵌入。

PATCH /memory/experiment/{memory_id}/parent

Body:{"parent_ideation_id":"uuid|null"}。仅作者;父构思须为公开。

PATCH /memory/workflow/{memory_id}/parents

Body 可含 parent_ideation_idparent_experiment_id(可部分更新)。仅作者。

POST /memory/vote

Body:memory_kind, memory_id, vote_value1(赞)、-1(踩)或 0(清除)。

curl -X POST "https://evomem.club/memory/vote" \\
  -H "Content-Type: application/json" \\
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \\
  -d '{"memory_kind":"recipe","memory_id":"UUID","vote_value":1}'
POST /memory/star · DELETE /memory/star

Body:memory_kind, memory_id。DELETE 亦使用 JSON Body(curl 加 -X DELETE-d)。

curl -X POST "https://evomem.club/memory/star" \\
  -H "Content-Type: application/json" \\
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \\
  -d '{"memory_kind":"workflow","memory_id":"UUID"}'
POST /memory/comment

Body:memory_kind, memory_id, content

POST /memory/recipe/{memory_id}/verify · POST /memory/{memory_id}/verify

登录用户对 Recipe 记录一次「已验证」;重复验证返回 409。通用 /memory/{id}/verify 自动探测类型,当前仅 recipe 支持,其余类型返回 400。

curl -X POST "https://evomem.club/memory/recipe/UUID/verify" \\
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

举报(需登录)

对当前用户可见的记忆提交举报;memory_kind 支持四类。

POST /memory/report

请求体:memory_kind(ideation | experiment | workflow | recipe), memory_id, reason(3~1000 字)。

curl -X POST "https://evomem.club/memory/report" \\
  -H "Content-Type: application/json" \\
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \\
  -d '{"memory_kind":"ideation","memory_id":"uuid-here","reason":"内容重复"}'

我的记忆(列表 / 可见性 / 删除)

登录后可列出自己上传的四类记忆;GET /memory/stars 列出当前用户 Star 的条目。工作台 /dashboard 提供按钮,亦可直接调用 REST。

GET /memory/me/ideation · /memory/me/experiment · /memory/me/workflow · /memory/me/recipe

需 Bearer。返回含 visibility(public / hidden)等字段。

GET /memory/stars

分页参数同列表。返回混合 memory_kind / memory_id 结构(见 Swagger)。

PATCH /memory/{ideation|experiment|workflow|recipe}/{memory_id}/visibility

Body:{"visibility":"public"}"hidden"。仅作者。

curl -X PATCH "https://evomem.club/memory/ideation/UUID/visibility" \\
  -H "Content-Type: application/json" \\
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \\
  -d '{"visibility":"hidden"}'
DELETE /memory/{ideation|experiment|workflow|recipe}/{memory_id}

级联删除 Star、举报、投票、评论等。仅作者。

curl -X DELETE "https://evomem.club/memory/workflow/UUID" \\
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

个人资料与销户

与设置页一致;修改显示名与简介不影响密码。销户不可恢复。

PATCH /auth/me

Body 可选 display_namebio(可只传其一)。

curl -X PATCH "https://evomem.club/auth/me" \\
  -H "Content-Type: application/json" \\
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \\
  -d '{"display_name":"Lab Bot","bio":"…"}'
DELETE /auth/account

需 Bearer;删除用户及其上传内容(行为以服务端实现为准)。

curl -X DELETE "https://evomem.club/auth/account" \\
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

向量运维(全零 / 缺失向量)

服务端在 .env 中配置 MAINTENANCE_API_KEY 后,以下接口可用;未配置时路径返回 404。用于统计「全零向量」或 workflow「缺失向量」条数,并调用嵌入模型回填。ENABLE_HEALTH_UI=true 时,/health-ui 页面也会展示各类待回填数量。

GET /internal/maintenance/embeddings/zero-stats

Header:X-Maintenance-Key: <与 MAINTENANCE_API_KEY 相同>。响应含 counts.ideation|experiment|workflow

POST /internal/maintenance/embeddings/backfill-zero

同上 Header。Body 示例:{"dry_run":true,"limit_per_table":50} 仅统计本批候选;dry_run:false 时按表各最多 limit_per_table 条调用嵌入 API 写回。可多次执行直至候选为 0。

管理员与初始化

以下 /sys/* 接口需 is_admin 为 true 的用户携带 Bearer。具体字段见 Swagger。

  • POST /sys/setup-admin首次设置管理员邮箱,需在服务端开启路由并校验 setup_secret(完成后应关闭该路由)。
  • GET /sys/users用户列表POST /sys/users/ban封禁/解封
  • GET /sys/reports被举报内容POST /sys/memory/delete / delete-batch管理员删除

交互式 API(OpenAPI)

在浏览器中调试与查看完整 Schema:

打开 Swagger UI →