cognee - 5行代码实现AI代理记忆系统
Demo . Learn more · Join Discord · Join r/AIMemory
通过可扩展的模块化ECL(提取、认知化、加载)流水线,为AI代理构建动态记忆系统,替代传统RAG方案。
🌐 Available Languages : Deutsch | Español | français | 日本語 | 한국어 | Português | Русский | 中文
通过Google Colab notebook、Deepnote notebook或入门代码库立即体验
您的贡献是推动本项目成为真正开源项目的核心力量。所有贡献都将被高度认可。详见CONTRIBUTING.md
支持通过pip、poetry、uv等Python包管理器安装。兼容Python 3.8至3.12版本
pip install cognee
可通过pip、poetry和uv安装本地仓库。使用pip安装时请确保版本高于21.3
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 UI进行文件认知化处理与查询
本地体验Cognee UI请访问此处
我们致力于为社区成员创造愉快且相互尊重的开源体验。详见行为准则