This project integrates Neo4j with AI models to generate Cypher queries from natural language prompts. It utilizes local AI models for natural language processing and a vector database approach for efficient querying.
This is the source code shown on my video tutorial, consider watching it first!
.
├── README.md # Project documentation
├── data # Database-related files
│ ├── courses.json # Course data
│ └── seed.js # Database seeding script
├── docker-compose.yml # Configuration for running Neo4j
├── other-examples # Additional use cases
│ ├── neo4j-vector.js # Example using vector search in Neo4j
│ └── rag # Retrieval-Augmented Generation example
│ ├── data # Sample data for RAG
│ │ └── javascript.txt # Text data for queries
│ ├── index.js # Implementation for RAG
│ ├── package-lock.json # Dependency lock file
│ └── package.json # Dependencies
├── package-lock.json # Dependency lock file
├── package.json # Project dependencies
├── prompts # AI-related prompts
│ ├── context.md # Context prompt template
│ ├── nlpToCypher.md # NLP to Cypher prompt template
│ └── responseTemplateFromJson.md # Response formatting template
├── references.txt # Related documentation/references
├── request.sh # Script for testing caching mechanism
├── script.txt # Miscellaneous script
└── src # Source code
├── ai.js # AI model interaction logic
└── index.js # Main application entry point
Ensure you have the following installed:
- Start Ollama
ollama serve
- Download AI models
ollama pull gemma:7b ollama pull deepseek-coder:6.7b
- Start Neo4j
docker-compose up -d
- Install dependencies
npm ci
- Seed the database
npm run seed
- Run the application
npm run dev
- Test caching mechanism (Run twice to observe caching behavior)
sh request.sh
- AI-powered natural language to Cypher query conversion
- Neo4j integration with vector search capabilities
- RAG (Retrieval-Augmented Generation) example included
- Database seeding for reproducible testing
- Dockerized Neo4j instance
Once the application is running, you can send natural language queries to the AI, which will convert them into optimized Cypher queries for Neo4j. The system caches responses for better performance on repeated queries.
Feel free to open issues and submit PRs for enhancements!
MIT License