Memory

Cognee Memory System

Try it

AI知识引擎 - 6行代码实现记忆系统。remember/recall/forget/improve循环,向量+图搜索,支持OpenClaw插件。

What it does

Cognee Memory System AI知识引擎 - 6行代码实现记忆系统

The skill document

Cognee Memory System

AI知识引擎 - 6行代码实现记忆系统

官网: https://cognee.ai
GitHub: https://github.com/topoteretes/cognee
安装: pip install cognee
OpenClaw插件: @cognee/cognee-openclaw


核心API

四大操作

操作功能说明
remember存储记忆永久存储到知识图谱
recall查询记忆自动路由最优搜索策略
forget删除记忆删除过时/错误记忆
improve优化学习持续学习提升准确性

快速开始

Python API

import cognee
import asyncio

async def main():
    # 存储到知识图谱
    await cognee.remember("Cognee turns documents into AI memory.")
    
    # 存储到会话缓存(快速)
    await cognee.remember("User prefers detailed explanations.", session_id="chat_1")
    
    # 查询(自动路由)
    results = await cognee.recall("What does Cognee do?")
    for result in results:
        print(result)
    
    # 删除
    await cognee.forget(dataset="main_dataset")

asyncio.run(main())

CLI

cognee-cli remember "Cognee turns documents into AI memory."
cognee-cli recall "What does Cognee do?"
cognee-cli forget --all
cognee-cli -ui  # 打开本地UI

配置

环境变量

# OpenAI API(必需)
export LLM_API_KEY="your-openai-key"

# 或使用其他LLM提供商
# 见: https://docs.cognee.ai/setup-configuration/llm-providers

# Cognee Cloud(可选)
export COGNEE_SERVICE_URL="https://your-instance.cognee.ai"
export COGNEE_API_KEY="ck_..."

使用场景

1. 客服Agent

用户:"我的发票有问题还没解决"
Cognee追踪:历史交互、失败操作、已解决案例、产品历史
Agent回复:"找到2个上月类似计费案例已解决,问题由支付系统同步延迟导致"

2. SQL Copilot(知识蒸馏)

用户:"如何计算客户留存率?"
Cognee追踪:专家SQL查询、工作流模式、schema结构、成功实现
Agent回复:"高级分析师解决了类似留存查询,这是他们的方案..."

3. 跨会话记忆

# Session 1
await cognee.remember("用户喜欢详细的解释", session_id="user_123")

# Session 2(跨会话查询)
results = await cognee.recall("用户偏好什么?", session_id="user_123")

OpenClaw插件安装

npm install @cognee/cognee-openclaw

插件自动集成:

  • SessionStart → 初始化记忆
  • PostToolUse → 捕获行动
  • UserPromptSubmit → 注入相关上下文
  • PreCompact → 跨上下文保留记忆
  • SessionEnd → 桥接到永久知识图谱

vs 其他记忆系统

功能我们现有Cognee
存储方式文件向量+图双存储
搜索方式关键词语义+关系
学习能力无forget+improve
跨Agent不支持共享知识图谱
可视化无CLI UI

部署选项

平台说明
Cognee Cloud托管服务
Modal无服务器,GPU自动扩展
Railway简化PaaS
Fly.io边缘部署
Render简单PaaS

示例代码

完整记忆循环

import cognee
import asyncio

async def memory_loop():
    # 1. 学习新知识
    await cognee.remember("用户正在学习Python编程")
    await cognee.remember("用户偏好边做边学的教学方式")
    
    # 2. 查询相关记忆
    results = await cognee.recall("用户的学习偏好是什么?")
    
    # 3. 根据反馈改进
    await cognee.improve("纠正对用户偏好的错误理解")
    
    # 4. 忘记错误记忆
    await cognee.forget("错误的假设")

asyncio.run(memory_loop())

安装状态

  • Python包:✅ 已安装 cognee
  • OpenClaw插件:需额外安装 @cognee/cognee-openclaw

Powered by Cognee | https://cognee.ai

Related skills

Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.

by Iván559 installs18 stars

Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.

by nssa.io1.0k installs47 stars

Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.

by johnpatternai22 installs8 stars

Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.

by Iván855 installs69 stars

Fetch raw ad creative, app, ranking, and revenue data from AdMapix as structured JSON.

by fly0pants4.3k installs296 stars

Run Git operations — commits, branches, merges, rebases, conflict resolution, and recovery — with safety rules enforced.

by Iván535 installs31 stars

More from smseow001

Browse all skills

AI architecture diagram generator supporting Mermaid charts. Generate system architecture, cloud architecture, neural network, graph theory, flowchart, ER di...

by SMS41 installs1 stars

让AI代理控制浏览器自动化网页操作。支持 Claude/GPT/Gemini/Ollama,可执行填表、购物、搜索等任务。

by smseow00120 installs

谷歌开源 AI 编程工作流 - 从需求到代码的快速转化。包含20个专项技能、规范开发流程、7大实战案例。

by smseow00117 installs

ComfyUI V8 秋叶中文版 全流程助手。提供安装检测、一键启动、工作流生成(文生图/图生图/ControlNet/InstantID等)、参数优化、故障排查、批量生成、模型管理等功能。All-in-one assistant for ComfyUI V8 (Aki bundle) with workflow...

by smseow00117 installs

硅谷多智能体量化交易系统 - 三级架构(研究员/分析师/交易员)+ 完整量化流程 + 新手平台推荐 + 策略指南。

by smseow00114 installs

将 OpenClaw 升级为 Claude-Code 引擎架构 - 并发执行/自我反思/向量检索/子代理系统/上下文压缩

by smseow00114 installs