概覽
什麼是 Graphiti?
Graphiti 是一個創新的框架,旨在為 AI 代理構建實時知識圖譜。它允許開發者創建動態和互聯的數據結構,增強人工智能系統的能力。通過利用 Graphiti,用戶可以高效地管理和可視化數據點之間的複雜關係,使其成為 AI 開發的重要工具。
Graphiti 的特點
- 實時數據處理:Graphiti 使知識圖譜能夠實時更新,確保 AI 代理可以訪問最新的信息。
- 用戶友好的界面:該框架提供直觀的界面,簡化了創建和管理知識圖譜的過程。
- 可擴展性:Graphiti 設計用於處理大型數據集,適合從小型項目到企業級解決方案的應用。
- 集成能力:它可以輕鬆與各種數據源和 API 集成,實現無縫的數據導入和導出。
- 可視化工具:Graphiti 包含內置的可視化工具,幫助用戶通過互動圖表理解數據之間的關係。
如何使用 Graphiti
- 安裝:首先通過您首選的包管理器安裝 Graphiti,或從官方庫下載。
- 設置:通過指定數據源和初始化框架來配置您的環境。
- 創建知識圖譜:使用提供的工具定義實體和關係,根據項目需求構建您的知識圖譜。
- 實時更新:實施實時數據源,以保持您的知識圖譜的最新狀態,確保 AI 代理能根據最新信息做出明智的決策。
- 可視化:利用可視化工具探索和分析您的知識圖譜,獲取數據關係的見解。
常見問題解答
問:Graphiti 支持哪些編程語言?
答:Graphiti 主要設計用於 JavaScript 和 Python,但可以通過 API 與其他語言集成。
問:Graphiti 適合大型應用程序嗎?
答:是的,Graphiti 是為處理大型數據集而構建的,並且可以根據應用程序的需求進行擴展。
問:我可以將 Graphiti 與現有數據庫集成嗎?
答:當然可以!Graphiti 支持與各種數據庫和數據源的集成,使其易於納入現有系統。
問:Graphiti 是否有可用的文檔?
答:是的,官方 Graphiti 網站上提供了全面的文檔,提供有關安裝、使用和最佳實踐的指導。
問:Graphiti 的授權是什麼?
答:Graphiti 授權使用 Apache-2.0 授權,允許個人和商業用途。
詳細
<a href="https://trendshift.io/repositories/12986" target="_blank"><img src="https://trendshift.io/api/badge/repositories/12986" alt="getzep%2Fgraphiti | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
</div>:star: Help us reach more developers and grow the Graphiti community. Star this repo!
<br />[!TIP] Check out the new MCP server for Graphiti! Give Claude, Cursor, and other MCP clients powerful Knowledge Graph-based memory.
Graphiti is a framework for building and querying temporally-aware knowledge graphs, specifically tailored for AI agents operating in dynamic environments. Unlike traditional retrieval-augmented generation (RAG) methods, Graphiti continuously integrates user interactions, structured and unstructured enterprise data, and external information into a coherent, queryable graph. The framework supports incremental data updates, efficient retrieval, and precise historical queries without requiring complete graph recomputation, making it suitable for developing interactive, context-aware AI applications.
Use Graphiti to:
- Integrate and maintain dynamic user interactions and business data.
- Facilitate state-based reasoning and task automation for agents.
- Query complex, evolving data with semantic, keyword, and graph-based search methods.
A knowledge graph is a network of interconnected facts, such as "Kendra loves Adidas shoes." Each fact is a "triplet" represented by two entities, or nodes ("Kendra", "Adidas shoes"), and their relationship, or edge ("loves"). Knowledge Graphs have been explored extensively for information retrieval. What makes Graphiti unique is its ability to autonomously build a knowledge graph while handling changing relationships and maintaining historical context.
Graphiti and Zep Memory
Graphiti powers the core of Zep's memory layer for AI Agents.
Using Graphiti, we've demonstrated Zep is the State of the Art in Agent Memory.
Read our paper: Zep: A Temporal Knowledge Graph Architecture for Agent Memory.
We're excited to open-source Graphiti, believing its potential reaches far beyond AI memory applications.
<p align="center"> <a href="https://arxiv.org/abs/2501.13956"><img src="images/arxiv-screenshot.png" alt="Zep: A Temporal Knowledge Graph Architecture for Agent Memory" width="700px"></a> </p>Why Graphiti?
Traditional RAG approaches often rely on batch processing and static data summarization, making them inefficient for frequently changing data. Graphiti addresses these challenges by providing:
- Real-Time Incremental Updates: Immediate integration of new data episodes without batch recomputation.
- Bi-Temporal Data Model: Explicit tracking of event occurrence and ingestion times, allowing accurate point-in-time queries.
- Efficient Hybrid Retrieval: Combines semantic embeddings, keyword (BM25), and graph traversal to achieve low-latency queries without reliance on LLM summarization.
- Custom Entity Definitions: Flexible ontology creation and support for developer-defined entities through straightforward Pydantic models.
- Scalability: Efficiently manages large datasets with parallel processing, suitable for enterprise environments.
Graphiti vs. GraphRAG
| Aspect | GraphRAG | Graphiti | | -- | - | | | Primary Use | Static document summarization | Dynamic data management | | Data Handling | Batch-oriented processing | Continuous, incremental updates | | Knowledge Structure | Entity clusters & community summaries | Episodic data, semantic entities, communities | | Retrieval Method | Sequential LLM summarization | Hybrid semantic, keyword, and graph-based search | | Adaptability | Low | High | | Temporal Handling | Basic timestamp tracking | Explicit bi-temporal tracking | | Contradiction Handling | LLM-driven summarization judgments | Temporal edge invalidation | | Query Latency | Seconds to tens of seconds | Typically sub-second latency | | Custom Entity Types | No | Yes, customizable | | Scalability | Moderate | High, optimized for large datasets |
Graphiti is specifically designed to address the challenges of dynamic and frequently updated datasets, making it particularly suitable for applications requiring real-time interaction and precise historical queries.
Installation
Requirements:
- Python 3.10 or higher
- Neo4j 5.26 / FalkorDB 1.1.2 or higher (serves as the embeddings storage backend)
- OpenAI API key (for LLM inference and embedding)
[!IMPORTANT] Graphiti works best with LLM services that support Structured Output (such as OpenAI and Gemini). Using other services may result in incorrect output schemas and ingestion failures. This is particularly problematic when using smaller models.
Optional:
- Google Gemini, Anthropic, or Groq API key (for alternative LLM providers)
[!TIP] The simplest way to install Neo4j is via Neo4j Desktop. It provides a user-friendly interface to manage Neo4j instances and databases.
pip install graphiti-core
or
poetry add graphiti-core
You can also install optional LLM providers as extras:
### Install with Anthropic support
pip install graphiti-core[anthropic]
### Install with Groq support
pip install graphiti-core[groq]
### Install with Google Gemini support
pip install graphiti-core[google-genai]
### Install with multiple providers
pip install graphiti-core[anthropic,groq,google-genai]
Quick Start
[!IMPORTANT] Graphiti uses OpenAI for LLM inference and embedding. Ensure that an
OPENAI_API_KEY
is set in your environment. Support for Anthropic and Groq LLM inferences is available, too. Other LLM providers may be supported via OpenAI compatible APIs.
For a complete working example, see the Quickstart Example in the examples directory. The quickstart demonstrates:
- Connecting to a Neo4j database
- Initializing Graphiti indices and constraints
- Adding episodes to the graph (both text and structured JSON)
- Searching for relationships (edges) using hybrid search
- Reranking search results using graph distance
- Searching for nodes using predefined search recipes
The example is fully documented with clear explanations of each functionality and includes a comprehensive README with setup instructions and next steps.
MCP Server
The mcp_server
directory contains a Model Context Protocol (MCP) server implementation for Graphiti. This server allows AI assistants to interact with Graphiti's knowledge graph capabilities through the MCP protocol.
Key features of the MCP server include:
- Episode management (add, retrieve, delete)
- Entity management and relationship handling
- Semantic and hybrid search capabilities
- Group management for organizing related data
- Graph maintenance operations
The MCP server can be deployed using Docker with Neo4j, making it easy to integrate Graphiti into your AI assistant workflows.
For detailed setup instructions and usage examples, see the MCP server README.
REST Service
The server
directory contains an API service for interacting with the Graphiti API. It is built using FastAPI.
Please see the server README for more information.
Optional Environment Variables
In addition to the Neo4j and OpenAi-compatible credentials, Graphiti also has a few optional environment variables. If you are using one of our supported models, such as Anthropic or Voyage models, the necessary environment variables must be set.
USE_PARALLEL_RUNTIME
is an optional boolean variable that can be set to true if you wish
to enable Neo4j's parallel runtime feature for several of our search queries.
Note that this feature is not supported for Neo4j Community edition or for smaller AuraDB instances,
as such this feature is off by default.
Using Graphiti with Azure OpenAI
Graphiti supports Azure OpenAI for both LLM inference and embeddings. To use Azure OpenAI, you'll need to configure both the LLM client and embedder with your Azure OpenAI credentials.
from openai import AsyncAzureOpenAI
from graphiti_core import Graphiti
from graphiti_core.llm_client import LLMConfig, OpenAIClient
from graphiti_core.embedder.openai import OpenAIEmbedder, OpenAIEmbedderConfig
from graphiti_core.cross_encoder.openai_reranker_client import OpenAIRerankerClient
### Azure OpenAI configuration
api_key = "<your-api-key>"
api_version = "<your-api-version>"
azure_endpoint = "<your-azure-endpoint>"
### Create Azure OpenAI client for LLM
azure_openai_client = AsyncAzureOpenAI(
api_key=api_key,
api_version=api_version,
azure_endpoint=azure_endpoint
)
### Create LLM Config with your Azure deployed model names
azure_llm_config = LLMConfig(
small_model="gpt-4.1-nano",
model="gpt-4.1-mini",
)
### Initialize Graphiti with Azure OpenAI clients
graphiti = Graphiti(
"bolt://localhost:7687",
"neo4j",
"password",
llm_client=OpenAIClient(
llm_config=azure_llm_config,
client=azure_openai_client
),
embedder=OpenAIEmbedder(
config=OpenAIEmbedderConfig(
embedding_model="text-embedding-3-small" # Use your Azure deployed embedding model name
),
client=azure_openai_client
),
# Optional: Configure the OpenAI cross encoder with Azure OpenAI
cross_encoder=OpenAIRerankerClient(
llm_config=azure_llm_config,
client=azure_openai_client
)
)
### Now you can use Graphiti with Azure OpenAI
Make sure to replace the placeholder values with your actual Azure OpenAI credentials and specify the correct embedding model name that's deployed in your Azure OpenAI service.
Using Graphiti with Google Gemini
Graphiti supports Google's Gemini models for both LLM inference and embeddings. To use Gemini, you'll need to configure both the LLM client and embedder with your Google API key.
Install Graphiti:
poetry add "graphiti-core[google-genai]"
### or
uv add "graphiti-core[google-genai]"
from graphiti_core import Graphiti
from graphiti_core.llm_client.gemini_client import GeminiClient, LLMConfig
from graphiti_core.embedder.gemini import GeminiEmbedder, GeminiEmbedderConfig
### Google API key configuration
api_key = "<your-google-api-key>"
### Initialize Graphiti with Gemini clients
graphiti = Graphiti(
"bolt://localhost:7687",
"neo4j",
"password",
llm_client=GeminiClient(
config=LLMConfig(
api_key=api_key,
model="gemini-2.0-flash"
)
),
embedder=GeminiEmbedder(
config=GeminiEmbedderConfig(
api_key=api_key,
embedding_model="embedding-001"
)
)
)
### Now you can use Graphiti with Google Gemini
Using Graphiti with Ollama (Local LLM)
Graphiti supports Ollama for running local LLMs and embedding models via Ollama's OpenAI-compatible API. This is ideal for privacy-focused applications or when you want to avoid API costs.
Install the models: ollama pull deepseek-r1:7b # LLM ollama pull nomic-embed-text # embeddings
from graphiti_core import Graphiti
from graphiti_core.llm_client.config import LLMConfig
from graphiti_core.llm_client.openai_client import OpenAIClient
from graphiti_core.embedder.openai import OpenAIEmbedder, OpenAIEmbedderConfig
from graphiti_core.cross_encoder.openai_reranker_client import OpenAIRerankerClient
### Configure Ollama LLM client
llm_config = LLMConfig(
api_key="abc", # Ollama doesn't require a real API key
model="deepseek-r1:7b",
small_model="deepseek-r1:7b",
base_url="http://localhost:11434/v1", # Ollama provides this port
)
llm_client = OpenAIClient(config=llm_config)
### Initialize Graphiti with Ollama clients
graphiti = Graphiti(
"bolt://localhost:7687",
"neo4j",
"password",
llm_client=llm_client,
embedder=OpenAIEmbedder(
config=OpenAIEmbedderConfig(
api_key="abc",
embedding_model="nomic-embed-text",
embedding_dim=768,
base_url="http://localhost:11434/v1",
)
),
cross_encoder=OpenAIRerankerClient(client=llm_client, config=llm_config),
)
### Now you can use Graphiti with local Ollama models
Ensure Ollama is running (ollama serve
) and that you have pulled the models you want to use.
Documentation
Status and Roadmap
Graphiti is under active development. We aim to maintain API stability while working on:
- Supporting custom graph schemas:
- Allow developers to provide their own defined node and edge classes when ingesting episodes
- Enable more flexible knowledge representation tailored to specific use cases
- Enhancing retrieval capabilities with more robust and configurable options
- Graphiti MCP Server
- Expanding test coverage to ensure reliability and catch edge cases
Contributing
We encourage and appreciate all forms of contributions, whether it's code, documentation, addressing GitHub Issues, or answering questions in the Graphiti Discord channel. For detailed guidelines on code contributions, please refer to CONTRIBUTING.
Support
Join the Zep Discord server and make your way to the #Graphiti channel!
伺服器配置
{
"mcpServers": {
"graphiti-memory": {
"transport": "stdio",
"command": "/Users/<user>/.local/bin/uv",
"args": [
"run",
"--isolated",
"--directory",
"/Users/<user>>/dev/zep/graphiti/mcp_server",
"--project",
".",
"graphiti_mcp_server.py",
"--transport",
"stdio"
],
"env": {
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USER": "neo4j",
"NEO4J_PASSWORD": "password",
"OPENAI_API_KEY": "sk-XXXXXXXX",
"MODEL_NAME": "gpt-4.1-mini"
}
}
}
}