Cognee是一個開源的AI記憶引擎框架,旨在為AI智慧體提供可靠的記憶功能。該項目的核心理念是透過僅需5行程式碼就能為AI應用和智慧體構建動態記憶系統。
Cognee採用了獨特的ECL(Extract, Cognify, Load)管道架構:
pip install cognee
import os
os.environ["LLM_API_KEY"] = "YOUR OPENAI_API_KEY"
import cognee
import asyncio
async def main():
# 向cognee添加文本
await cognee.add("Natural language processing (NLP) is an interdisciplinary subfield of computer science and information retrieval.")
# 生成知識圖譜
await cognee.cognify()
# 查詢知識圖譜
results = await cognee.search("Tell me about NLP")
# 顯示結果
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.
創建.env
文件進行配置:
LLM_API_KEY=your_openai_api_key
# 其他配置選項...
Cognee代表了AI記憶管理的新方向,透過簡單易用的API和強大的技術架構,為開發者提供了構建智能記憶系統的完整解決方案。無論是用於構建智能對話系統、知識管理平台還是複雜的AI智慧體,Cognee都能提供可靠的記憶基礎設施支持。