Graphiti-Pydantic is a Python project that demonstrates how to build, search, and interact with a temporal knowledge graph of Large Language Models (LLMs) using Graphiti Core, Pydantic AI, and Neo4j. The project provides scripts and an agent for adding, evolving, and querying knowledge about LLMs, with a focus on temporal and factual accuracy.
- Knowledge Graph Construction: Add structured and unstructured episodes (facts) about LLMs to a Neo4j-powered knowledge graph.
- Temporal Reasoning: Track the evolution of LLMs and their facts over time.
- Hybrid Search: Perform semantic and BM25-based searches over the knowledge graph.
- Conversational Agent: Interact with the knowledge graph using a Pydantic AI-powered agent.
- Extensible Recipes: Use and customize search recipes for advanced graph queries.
- Python 3.8+
- Neo4j (local or remote instance)
- See
requirements.txt
for all Python dependencies.
- Clone the repository:
git clone https://github.com/devjothish/Graphiti-Pydantic.git cd Graphiti-Pydantic
- Create and activate a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables:
Create a
.env
file in the project root with the following content:Adjust values as needed for your Neo4j and OpenAI setup.NEO4J_URI=bolt://localhost:7687 NEO4J_USER=neo4j NEO4J_PASSWORD=your_password OPENAI_API_KEY=your_openai_api_key # Only needed for agent.py MODEL_CHOICE=gpt-4.1-mini # Optional, for agent.py
Run the quickstart script to initialize the graph, add example episodes, and perform searches:
python quickstart.py
- Adds sample facts about LLMs (text and JSON episodes)
- Demonstrates hybrid search, center node reranking, and node search with recipes
Run the evolution script to simulate how LLMs and their facts change over time:
python llm_evolution.py
- Adds, updates, and benchmarks LLMs in the knowledge graph
- Shows how to update facts and track temporal changes
Run the agent to interact with the knowledge graph using natural language:
python agent.py
- Provides a conversational interface powered by Pydantic AI and Graphiti
- Answers questions about LLMs using the knowledge graph
- Streams responses with markdown formatting
quickstart.py
— Example script for initializing, populating, and searching the knowledge graphllm_evolution.py
— Script to simulate the evolution and benchmarking of LLMs over timeagent.py
— Conversational agent for querying the knowledge graphrequirements.txt
— Python dependencies.env
— Environment variables (not committed to version control)
All dependencies are listed in requirements.txt
. Key libraries include:
graphiti-core
— Knowledge graph construction and searchpydantic-ai
— Conversational agent frameworkneo4j
— Graph databasepython-dotenv
— Environment variable managementrich
— Console output formatting
This project is licensed under the Apache License 2.0. See the source files for details.