Skip to main content

Neo4j Schema Query Builder

pip install llama-index-tools-neo4j

The Neo4jQueryToolSpec class provides a way to query a Neo4j graph database based on a provided schema definition. The class uses a language model to generate Cypher queries from user questions and has the capability to recover from Cypher syntax errors through a self-healing mechanism.

Table of Contents

Usage

Initialization

Initialize the Neo4jQueryToolSpec class with:

from llama_index.tools.neo4j import Neo4jQueryToolSpec
from llama_index.llms.openai import OpenAI
from llama_index.core.agent.workflow import FunctionAgent

gds_db = Neo4jQueryToolSpec(
    url="neo4j-url",
    user="neo4j-user",
    password="neo4j=password",
    llm=llm,
    database="neo4j",
)

tools = gds_db.to_tool_list()
agent = FunctionAgent(
    tools=tools,
    llm=OpenAI(model="gpt-4.1"),
)

Where:

  • url: Connection string for the Neo4j database.
  • user: Username for the Neo4j database.
  • password: Password for the Neo4j database.
  • llm: A language model for generating Cypher queries (any type of LLM).
  • database: The database name.

Running a Query

To use the agent:

# use agent
resp = await agent.run("Where is JFK airport is located?")
Generated Cypher:

MATCH (p:Port {port_code: 'JFK'})
RETURN p.location_name_wo_diacritics AS Location

Final answer:
'The port code JFK is located in New York, United States.'

Features

  • Schema-Based Querying: The class extracts the Neo4j database schema to guide the Cypher query generation.
  • Self-Healing: On a Cypher syntax error, the class corrects itself to produce a valid query.
  • Language Model Integration: Uses a language model for natural and accurate Cypher query generation.

Metadata

Release files for llama-index-tools-neo4j 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-tools-neo4j 0.7.0
File Size Uploaded Provenance Actions
llama_index_tools_neo4j-0.7.0.tar.gz 7.3 kB Without provenance Details for llama_index_tools_neo4j-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-tools-neo4j 0.7.0
File Interpreter ABI Platform Actions
llama_index_tools_neo4j-0.7.0-py3-none-any.whl Python 3 none any Details for llama_index_tools_neo4j-0.7.0-py3-none-any.whl

Total release size: 14.5 kB

Release files / llama_index_tools_neo4j-0.7.0.tar.gz

Download URL llama_index_tools_neo4j-0.7.0.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0a891bda5b2be0373ba912b064ca95b03162d03d0a8f768e6aa04075509fe873
BLAKE2b-256 checksum
How to use checksums
926b6a8b11f415cca950886d89521048208f73e3e00d0173a36a57db2868fe67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / llama_index_tools_neo4j-0.7.0-py3-none-any.whl

Download URL llama_index_tools_neo4j-0.7.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a091f486820597f263ab0fcbb15d8765c61fd6a80d4b13c70596b12db70b1a14
BLAKE2b-256 checksum
How to use checksums
614b2b43ddba32ff4f962c1d34fab887be76f2332ca9352351df3f77fd309999
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for llama-index-tools-neo4j 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page