Registry / database / neo4j-graphrag

neo4j-graphrag

JSON →
library1.17.0pypypiunverified

The neo4j-graphrag library provides Pythonic access and utilities for integrating with Neo4j's GraphRAG (Retrieval Augmented Generation) features. It simplifies building Knowledge Graphs from unstructured text, performing vector embeddings, and executing RAG queries against a Neo4j graph database. The current version is 1.14.1, with a release cadence that is quite active, often seeing minor releases monthly.

pip install neo4j-graphrag
INSTALL
IMPORT
SIG · NEO4J-GRAPHRAG
N
neo4j-graphrag
databasepythonv1.17.0
Install
11.4s avg
Import
—
Disk
275MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.17.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.940 runs
installs and imports cleanly · install 0.0s · import 0.000s · 276.2MB
glibc
py 3.10–3.940 runs
installs and imports cleanly · install 11.4s · import 0.000s · 267MB
275MB installed
● package 275MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GraphRAGPipeline
✓ from neo4j_graphrag import GraphRAGPipeline
✗ from neo4j_graphrag import GraphRAGPipeline

This quickstart demonstrates how to set up and use the `GraphRAGPipeline` with an OpenAI LLM to query a Neo4j knowledge graph. It requires Neo4j to be running and accessible, and an OpenAI API key. Ensure `NEO4J_URI`, `NEO4J_USERNAME`, `NEO4J_PASSWORD`, and `OPENAI_API_KEY` environment variables are set.

import os from neo4j import GraphDatabase from neo4j_graphrag.graph_rag_pipeline import GraphRAGPipeline from neo4j_graphrag.llm import OpenAILLM # --- Configuration (Set environment variables or replace placeholders) --- NEO4J_URI = os.environ.get("NEO4J_URI", "bolt://localhost:7687") NEO4J_USERNAME = os.environ.get("NEO4J_USERNAME", "neo4j") NEO4J_PASSWORD = os.environ.get("NEO4J_PASSWORD", "password") NEO4J_DATABASE = os.environ.get("NEO4J_DATABASE", "neo4j") OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY", "") # Required for OpenAILLM if not all([NEO4J_URI, NEO4J_USERNAME, NEO4J_PASSWORD, OPENAI_API_KEY]): print("Warning: Please set NEO4J_URI, NEO4J_USERNAME, NEO4J_PASSWORD, and OPENAI_API_KEY environment variables for a runnable example.") print("Using default values for Neo4j, which may not connect without a running instance.") print("OpenAI API key is missing. The LLM initialization might fail or proceed without API calls.") try: # 1. Initialize Neo4j Driver driver = GraphDatabase.driver(NEO4J_URI, auth=(NEO4J_USERNAME, NEO4J_PASSWORD)) # Verify connection to ensure Neo4j is reachable and credentials are correct driver.verify_connectivity() print("Neo4j connection verified successfully.") # 2. Initialize your chosen LLM (e.g., OpenAI) llm = OpenAILLM(api_key=OPENAI_API_KEY) # 3. Initialize the GraphRAG pipeline # This pipeline is designed to work with a knowledge graph. For best results, # ensure your Neo4j database has relevant data, possibly built using SimpleKGPipeline. pipeline = GraphRAGPipeline( llm=llm, graph_driver=driver, database=NEO4J_DATABASE ) # 4. Ask a question to the pipeline question = "Who is the CEO of Neo4j?" print(f"\nQuestion: {question}") response = pipeline.query(question) print(f"Answer: {response.answer}") except Exception as e: print(f"An error occurred during quickstart: {e}") finally: if 'driver' in locals(): driver.close() print("Neo4j driver closed.")
Debug
Known issues
breakingPython 3.9 support was dropped in version 1.12.0. Additionally, Python 3.15 and newer are not yet supported (requires_python: <3.15,>=3.10.0).
fix
Ensure your project uses Python versions between 3.10 and 3.14 (inclusive). Downgrade Python if necessary or wait for future `neo4j-graphrag` updates.
affects: >=1.12.0
gotchaAs of version 1.14.1, schema extraction for entity labels explicitly forbids the use of `__` (double underscore) prefixes or suffixes. This may affect existing knowledge graphs or data ingestion pipelines that use such naming conventions.
fix
Avoid `__` (double underscore) at the beginning or end of entity labels when extracting schema or designing your graph data model.
affects: >=1.14.1
breakingVersion 1.13.0 introduced significant changes for LLM integrations, including support for structured output in `LLMInterfaceV2`, `OpenAILLM`, `VertexAILLM`, and tool calling for `OllamaLLM`. If you were interacting with these LLMs directly or expecting specific unstructured text outputs, your code may need adjustment.
fix
Review your LLM interaction patterns. If using direct LLM calls or specific output parsing, check the updated API for structured output methods and tool calling. Adapt your code to handle the new capabilities or maintain compatibility if relying on older patterns.
affects: >=1.13.0
gotchaVersion 1.14.0 fixed usage of deprecated APOC procedures. If you are using an older version of `neo4j-graphrag` with a newer Neo4j database version (e.g., Neo4j 5.x) that has removed or changed older APOC procedures, you might encounter errors.
fix
Upgrade to `neo4j-graphrag` version 1.14.0 or newer to ensure compatibility with modern Neo4j versions and their APOC library.
affects: <1.14.0
Upgrade
Version history
1.17.0latest on PyPI · released May 27, 2026
Audit
Dependencies
neo4jrequiredCore dependency for connecting to Neo4j database (requires >=5.19.0,<6.0.0)
openaioptionalFor using OpenAILLM
google-cloud-aiplatformoptionalFor using VertexAILLM
mistralaioptionalFor using MistralAILLM
ollamaoptionalFor using OllamaLLM
pypdfoptionalFor PDF document loading (e.g., PdfLoader)
Agent activity
53 hits · last 30 days
node
48
OpenAI (training)
1
Resources
neo4j-graphrag — pip install neo4j-graphrag · libregistry