Daniel Chalef 7f7a17c926
chore: update dependencies and refactor type hinting (#339)
* Bump version from 0.9.0 to 0.9.1 in pyproject.toml and update google-genai dependency to >=0.1.0

* Bump version from 0.9.1 to 0.9.2 in pyproject.toml

* Update google-genai dependency version to >=0.8.0 in pyproject.toml

* loc file

* Update pyproject.toml to version 0.9.3, restructure dependencies, and modify author format. Remove outdated Google API key note from README.md.

* upgrade poetry and ruff

* Update README.md to include installation instructions for Graphiti with Google Gemini support

* fix to deps since peotry doesn't fully implement PEP 735

* Refactor string formatting in various files to use single quotes for consistency and improve readability. This includes updates in agent.ipynb, quickstart.py, multiple prompt files, and ingest.py and retrieve.py modules.

* Remove optional dependencies from pyproject.toml to streamline project requirements.
2025-04-09 08:05:26 -07:00
..

Graphiti Quickstart Example

This example demonstrates the basic functionality of Graphiti, including:

  1. Connecting to a Neo4j database
  2. Initializing Graphiti indices and constraints
  3. Adding episodes to the graph
  4. Searching the graph with semantic and keyword matching
  5. Exploring graph-based search with reranking using the top search result's source node UUID
  6. Performing node search using predefined search recipes

Prerequisites

  • Neo4j Desktop installed and running
  • A local DBMS created and started in Neo4j Desktop
  • Python 3.9+
  • OpenAI API key (set as OPENAI_API_KEY environment variable)

Setup Instructions

  1. Install the required dependencies:
pip install graphiti-core
  1. Set up environment variables:
# Required for LLM and embedding
export OPENAI_API_KEY=your_openai_api_key

# Optional Neo4j connection parameters (defaults shown)
export NEO4J_URI=bolt://localhost:7687
export NEO4J_USER=neo4j
export NEO4J_PASSWORD=password
  1. Run the example:
python quickstart.py

What This Example Demonstrates

  • Graph Initialization: Setting up the Graphiti indices and constraints in Neo4j
  • Adding Episodes: Adding text content that will be analyzed and converted into knowledge graph nodes and edges
  • Edge Search Functionality: Performing hybrid searches that combine semantic similarity and BM25 retrieval to find relationships (edges)
  • Graph-Aware Search: Using the source node UUID from the top search result to rerank additional search results based on graph distance
  • Node Search Using Recipes: Using predefined search configurations like NODE_HYBRID_SEARCH_RRF to directly search for nodes rather than edges
  • Result Processing: Understanding the structure of search results including facts, nodes, and temporal metadata

Next Steps

After running this example, you can:

  1. Modify the episode content to add your own information
  2. Try different search queries to explore the knowledge extraction
  3. Experiment with different center nodes for graph-distance-based reranking
  4. Try other predefined search recipes from graphiti_core.search.search_config_recipes
  5. Explore the more advanced examples in the other directories

Understanding the Output

Edge Search Results

The edge search results include EntityEdge objects with:

  • UUID: Unique identifier for the edge
  • Fact: The extracted fact from the episode
  • Valid at/invalid at: Time period during which the fact was true (if available)
  • Source/target node UUIDs: Connections between entities in the knowledge graph

Node Search Results

The node search results include EntityNode objects with:

  • UUID: Unique identifier for the node
  • Name: The name of the entity
  • Content Summary: A summary of the node's content
  • Node Labels: The types of the node (e.g., Person, Organization)
  • Created At: When the node was created
  • Attributes: Additional properties associated with the node