# Graphiti — Temporal AI Knowledge Graph by Zep > Build dynamic knowledge graphs from AI agent conversations. Graphiti tracks entity changes over time, resolves contradictions, and provides temporal-aware queries. ## Install Copy the content below into your project: ## Quick Use ```bash pip install graphiti-core ``` ```python from graphiti_core import Graphiti from graphiti_core.llm_client import AnthropicClient graphiti = Graphiti( uri="bolt://localhost:7687", llm_client=AnthropicClient(), ) await graphiti.build_indices() # Add episodes (conversations) await graphiti.add_episode( name="user_onboarding", episode_body="Alice is a senior engineer at Acme Corp working on payments.", source_description="User onboarding conversation", ) # Search the graph results = await graphiti.search("Who works at Acme Corp?") for r in results: print(r.fact) # "Alice is a senior engineer at Acme Corp" ``` ## What is Graphiti? Graphiti is an open-source library for building temporal knowledge graphs from AI agent interactions. Unlike static knowledge bases, Graphiti tracks how entities and relationships change over time, resolves contradictions, and maintains a living graph that evolves with every conversation. **Answer-Ready**: Graphiti is an open-source temporal knowledge graph library by Zep. It builds dynamic entity-relationship graphs from AI agent conversations, tracks changes over time, resolves contradictions, and provides temporal-aware search. Works with Claude and GPT. **Best for**: AI agent developers building systems with evolving knowledge. **Works with**: Neo4j, Claude, GPT, any LLM. **Setup time**: Under 10 minutes (requires Neo4j). ## Core Features ### 1. Automatic Entity Extraction ```python # From conversation text, Graphiti extracts: await graphiti.add_episode( name="meeting_notes", episode_body="Bob joined the payments team last Monday. He previously worked at Stripe.", ) # Entities: Bob (person), Payments Team (team), Stripe (company) # Relations: Bob --joined--> Payments Team (date: last Monday) # Bob --previously_worked_at--> Stripe ``` ### 2. Temporal Tracking Every fact has a time dimension: ```python # March: "Alice uses React for frontend" # June: "Alice switched to Vue.js" results = await graphiti.search("What framework does Alice use?") # Returns: "Alice uses Vue.js" (knows React is outdated) # But you can also query historically: results = await graphiti.search("What did Alice use in March?") # Returns: "Alice used React" ``` ### 3. Contradiction Resolution ```python # Episode 1: "The API uses REST" # Episode 2: "We migrated the API to GraphQL" # Graphiti detects the contradiction and updates the graph: # Old edge: API --uses--> REST (invalidated) # New edge: API --uses--> GraphQL (current) ``` ### 4. Hybrid Search ```python # Semantic search results = await graphiti.search("payment processing architecture") # With time filter results = await graphiti.search( "team changes", center_node_uuid=alice_uuid, num_results=10, ) ``` ### 5. Graph Visualization Query the Neo4j database directly for visualization: ```cypher MATCH (n)-[r]->(m) WHERE n.name = 'Alice' RETURN n, r, m ``` ## Architecture ``` Conversations/Episodes ↓ Graphiti Engine ├── Entity Extractor (LLM) ├── Relation Extractor (LLM) ├── Contradiction Resolver (LLM) └── Temporal Manager ↓ Neo4j Graph Database ├── Entities (nodes) ├── Relations (edges with timestamps) └── Episodes (source tracking) ↓ Hybrid Search (semantic + graph traversal) ``` ## Requirements - Python 3.10+ - Neo4j 5.x (local or Aura cloud) - LLM API key (Anthropic or OpenAI) ## FAQ **Q: How does Graphiti compare to basic RAG?** A: RAG retrieves static text chunks. Graphiti maintains structured, evolving knowledge with entity relationships and temporal awareness. **Q: Can I use it without Neo4j?** A: Currently Neo4j is required. It is the graph database backend for entity/relation storage. **Q: Is it related to Zep?** A: Yes, Graphiti is built by the Zep team. Zep uses Graphiti internally for its knowledge graph features. ## Source & Thanks > Created by [Zep AI](https://github.com/getzep). Licensed under Apache 2.0. > > [getzep/graphiti](https://github.com/getzep/graphiti) — 3k+ stars ## 快速使用 ```bash pip install graphiti-core ``` 从 AI 代理对话自动构建时间感知的知识图谱。 ## 什么是 Graphiti? Graphiti 是开源时间知识图谱库。从 AI 代理交互中构建动态实体关系图,追踪变化、解决矛盾、提供时间感知搜索。 **一句话总结**:Zep 出品的开源时间知识图谱,从 AI 对话构建动态实体关系图,追踪变化和解决矛盾。 **适合人群**:构建有进化知识的 AI 代理系统的开发者。**需要**:Neo4j + LLM API。 ## 核心功能 ### 1. 自动实体提取 从对话中提取人物、组织、技术等实体和关系。 ### 2. 时间追踪 每个事实有时间维度,知道哪些信息已过时。 ### 3. 矛盾解决 自动检测和处理矛盾信息。 ### 4. 混合搜索 语义搜索 + 图遍历。 ## 常见问题 **Q: 和 RAG 比较?** A: RAG 检索静态文本,Graphiti 维护结构化、进化的知识图谱。 **Q: 和 Zep 什么关系?** A: Zep 团队开发,Zep 内部使用 Graphiti 的知识图谱功能。 ## 来源与致谢 > [getzep/graphiti](https://github.com/getzep/graphiti) — 3k+ stars, Apache 2.0 --- Source: https://tokrepo.com/en/workflows/1c08f869-885b-48e3-b097-f9377d6a4cb4 Author: Agent Toolkit