This project contains two AI-powered chatbot agents:
An inventory chatbot that translates natural language questions into executable SQL queries against a SQLite database. It can accurately answer operational questions about assets, vendors, stock, and much more.
An interactive knowledge graph agent that translates natural language into Cypher queries for Neo4j. It supports full CRUD operations:
- Add: Store new facts and relationships ("Remember that John works at Microsoft")
- Inquire: Search for information ("Who works at Microsoft?")
- Update: Modify existing facts ("Change John's company to Google")
- Delete: Remove information ("Forget about John")
Both agents maintain conversation history and include intelligent error correction.
Below is the system architecture showing how the LangGraph state machine routes intent, generates SQL, executes queries, and self-corrects errors.
The Neo4j agent follows a similar pattern but handles CRUD operations (Create, Read, Update, Delete) on a graph database:
- Classifies user intent into add/inquire/edit/delete/chitchat
- Generates appropriate Cypher queries
- Executes against Neo4j database
- Self-corrects errors with context-aware retry logic
- Maintains conversation history across sessions
This project requires Python 3.9+ and uses several external libraries. All dependencies are locked in the requirements.txt file.
Key dependencies include:
- langchain & langchain-openai
- langgraph
- python-dotenv
- sqlite3 (Built into Python)
- neo4j (Python driver for Neo4j database)
This project requires an OpenAI API key and database credentials.
-
Create a file named
.envin the root directory of the project. -
Add your credentials like this:
# OpenAI Configuration
PROVIDER=openai
MODEL_API_KEY=your_openai_api_key_here
MODEL_NAME=gpt-4o-mini
# Neo4j Configuration (for Knowledge Graph Agent)
NEO4J_URI=neo4j+s://your-instance.databases.neo4j.io
NEO4J_USERNAME=your_username
NEO4J_PASSWORD=your_passwordFor Neo4j Aura (Cloud):
- Sign up at neo4j.com/aura
- Create a free instance
- Copy the connection URI, username, and password to your
.envfile
Open your terminal, navigate to the project folder, and run:
pip install -r requirements.txtBefore running the SQL bot, you must provide your SQLite database.
Replace the inventory_chatbot.db file with your own database, or run the setup script:
python setup_database.pyThe Neo4j agent will automatically create nodes and relationships as you add information. No initial setup required - just ensure your Neo4j instance is running and credentials are in .env.
To run the inventory chatbot against your SQLite database:
python main_sql.pyTo run the knowledge graph chatbot:
python main_neo4j.pySQL Agent:
You: How many items are in stock?
Bot: There are 150 items currently in stock.
Neo4j Agent:
You: Remember that Alice works at Google
Bot: Got it! I've stored that information.
You: Who works at Google?
Bot: Alice works at Google.
You: Update Alice's company to Microsoft
Bot: Updated successfully!
built by Asser =)