Last translated: 09 Jun 2025

Translation Not Available Yet

This repository's README hasn't been translated yet. Once translated, it will be easier to read and understand in your native language (中文).

Once translated, you'll be able to submit a PR to the repository.

Once translated, you'll be able to submit a PR to the repository.

Cognee Logo

cognee - 5行代码实现AI代理记忆系统

Demo . Learn more · Join Discord · Join r/AIMemory

GitHub forks GitHub stars GitHub commits Github tag Downloads License Contributors

cognee - Memory for AI Agents  in 5 lines of code | Product Hunt

topoteretes%2Fcognee | Trendshift

通过可扩展的模块化ECL(提取、认知化、加载)流水线,为AI代理构建动态记忆系统,替代传统RAG方案。

更多应用场景评估结果

🌐 Available Languages : Deutsch | Español | français | 日本語 | 한국어 | Português | Русский | 中文

Why cognee?

核心特性

  • 互联检索历史对话、文档、图像及音频转录内容
  • 替代RAG系统,降低开发成本与工作量
  • 仅用Pydantic即可将数据加载至图数据库和向量数据库
  • 支持从30+数据源摄取时进行数据加工

快速开始

通过Google Colab notebookDeepnote notebook入门代码库立即体验

贡献指南

您的贡献是推动本项目成为真正开源项目的核心力量。所有贡献都将被高度认可。详见CONTRIBUTING.md

📦 安装指南

支持通过pippoetryuv等Python包管理器安装。兼容Python 3.8至3.12版本

pip安装方式

pip install cognee

本地安装

可通过pippoetryuv安装本地仓库。使用pip安装时请确保版本高于21.3

UV安装(含所有可选依赖)

uv sync --all-extras

💻 基础用法

环境配置

import os
os.environ["LLM_API_KEY"] = "YOUR OPENAI_API_KEY"

也可通过创建.env文件设置变量,参考模板文件。如需使用不同LLM供应商,详见文档

基础示例

以下脚本将运行默认处理流水线:

import cognee
import asyncio


async def main():
    # Add text to cognee
    await cognee.add("Natural language processing (NLP) is an interdisciplinary subfield of computer science and information retrieval.")

    # Generate the knowledge graph
    await cognee.cognify()

    # Query the knowledge graph
    results = await cognee.search("Tell me about NLP")

    # Display the results
    for result in results:
        print(result)


if __name__ == '__main__':
    asyncio.run(main())

示例输出:

  Natural Language Processing (NLP) is a cross-disciplinary and interdisciplinary field that involves computer science and information retrieval. It focuses on the interaction between computers and human language, enabling machines to understand and process natural language.

我们的论文已发布!点击阅读

cognee paper

可视化界面

可通过Cognee UI进行文件认知化处理与查询

Cognee UI界面

本地体验Cognee UI请访问此处

架构解析

cognee concept diagram

演示案例

  1. 什么是AI记忆系统:

了解cognee

  1. 简易GraphRAG演示

GraphRAG基础演示

  1. 基于Ollama的cognee

本地模型运行示例

行为准则

我们致力于为社区成员创造愉快且相互尊重的开源体验。详见行为准则

💫 贡献者名单

contributors

项目星标历史

Star History Chart