A versatile LangGraph-powered chatbot that connects to different database types (GraphDB, PostgreSQL, AWS RDS, AWS Neptune) for querying power system equipment data.
- Multi-Database Support: Compatible with both graph databases (GraphDB, AWS Neptune) and relational databases (PostgreSQL, AWS RDS)
- Advanced LLM Integration:
- Auto model selection based on query complexity
- Manual model selection (Gemini, Llama3)
- Optimized query generation
- Sophisticated Query Processing:
- Automatic conversion from natural language to appropriate query language (SPARQL/SQL)
- Query validation and optimization
- Result caching for better performance
- Power System Domain Specialized:
- Built-in knowledge of electrical grid equipment
- Specialized schema for transformers, lines, substations, etc.
- Interactive Web Interface:
- Simple and intuitive chat interface
- Database and model selection options
- Connection configuration capabilities
The application follows a multi-stage processing pipeline powered by LangGraph:
- Model Selection: Chooses between Gemini and Llama3 models based on user preference or query complexity
- Query Optimization: Converts natural language to the appropriate query language
- Query Validation: Checks for syntax errors and semantic correctness
- Query Execution: Executes the validated query against the selected database
- Response Generation: Creates a formatted response from the query results
The system supports both relational and graph database schemas for power system equipment:
- Equipment (id, name, description, type)
- Transformer (id, name, apparent_power, voltage_level, status)
- Terminal (id, name, connected)
- Substation (id, name, latitude, longitude)
- Line (id, name, length, voltage_level)
- Various relationship tables (EquipmentSubstation, TerminalConnection)
- Similar entities as vertices with relationships defined as edges
- Supports both SPARQL and Gremlin query languages for AWS Neptune
See the guide.txt file for detailed installation instructions.
- Clone this repository
- Install dependencies (see
install_deps.txt
for details) - Configure your
.env
file with API keys and database connection (see.env.example
) - Run the application:
python main.py
orgunicorn --bind 0.0.0.0:5000 --reuse-port --reload main:app
- Open http://localhost:5000 in your browser
The system can answer a wide range of questions about power system equipment:
- "What are all the transformers with voltage level above 300kV?"
- "Show me the substations located in the northern region"
- "Which terminal connects transformer TX001 to line L1?"
- "List all equipment at the Main Substation"
This project requires:
- Google API key for Gemini model access
- GROQ API key for Llama3 model access (optional)
- Database credentials if connecting to real databases
- [Your Name/Team]
[Your License Information]