A lightweight AI agent-based framework that converts natural language queries into Cypher scripts for Neo4j, leveraging LLMs for precise query generation.
- Git
- Miniconda (with Mamba)
- Clone the repository:
git clone git@github.com:nickzren/text-to-cypher.git
- Initialize conda environment:
cd text-to-cypher mamba env create -f environment.yml
- Update the
.env
file to setOPENAI_API_KEY
.
- Init environment:
cd text-to-cypher conda activate text-to-cypher
- Run example scripts:
# autogen framework python src/cypher_autogen.py --query "Show compounds that treat both type 2 diabetes mellitus and hypertension." # crewai framework python src/cypher_crewai.py --query "Find all genes that participate in the mitotic spindle checkpoint and are expressed in the lung."
The file data/input/neo4j_schema.json
contains a Neo4j schema dump. While the example uses the Hetionet Neo4j database, the dump_neo4j_schema.py script can be used to dump the schema from any Neo4j database.
To set up the Hetionet Neo4j Docker container locally, follow the instructions from this link.
If you need to dump the schema from your own Neo4j instance, first update the .env
file to set DB_URL
and DB_NAME
.
Then, run the following command to dump the schema:
python src/dump_neo4j_schema.py --output_dir data/input/
You can also access the Neo4j Browser at http://localhost:7474 to run the Cypher queries generated by the text-to-cypher framework.