AI-Database-Query-Assistant: A Streamlit-based system that combines OpenAI GPT-3.5 and ChromaDB vector database to convert text to SQL queries. It can be used as a self-built reference framework.
Open source project maintained by Paulisure (Paul Loupe) on GitHub AI-Database-Query-Assistant。This is a utility that demonstrates how to convert natural language into SQL queries and run them through an interactive interface.
overview of items
The project aims to build a Natural Language → SQL Query System, and integrates the following technical components:
- using OpenAI’s GPT-3.5 The model converts a user’s natural language request into SQL query statements.
- use ChromaDB As a vector database, it is used for similarity retrieval of historical queries.
- Front-end interface adopts Streamlit Framework for users to interact through web pages.
Main functional highlights
- natural language query processing: Users enter ordinary English questions, such as “Who are the top 5 customers by total purchase amount?”, The system will automatically generate the corresponding SQL query.
- vector similarity retrieval: With ChromaDB, the system can find historical queries similar to the current input statement, improving the accuracy and consistency of generated results.
- Interactive web display: The interface built using Streamlit makes user operations more intuitive, supporting entering questions, viewing results, and even automatically generating chart visualizations.
- automatic visual: Query results can be displayed in real-time charts through Plotly Express, making the experience more friendly.
- Sample query library: Include examples such as “Which genre generates the most revenue” and “Calculate the average invoice amount by country” to help users get started quickly.
Technology stack and usage
| technology | use |
|---|---|
| GPT-3.5 | Convert natural language to SQL |
| ChromaDB | Vector database that supports similar query retrieval |
| Streamlit | Used to build web interactive interfaces |
| Plotly Express | Used to generate data visualization charts |
| SQLite (Chinook database) | As a back-end database, the architecture includes common table structures such as customers, artists, albums, audio tracks, and invoices, which are used to query presentations. |
Brief steps to use:
- After cloning the warehouse, create a virtual environment locally and install dependencies (
requirements.txtdefined in). - Configure the OpenAI API key by
.streamlit/secrets.tomlFile preservation. - Launch the application:
streamlit run streamlit_app.py, access the local address in the browser: such as http://localhost:8501You can use the system. You can use the system.
summary
AI-Database-Query-Assistant It is a lightweight tool that allows users to interact with databases through natural language. It integrates GPT-3.5 generated SQL, ChromaDB semantic retrieval and Streamlit front-end display, and combines Plotly to achieve intuitive charts. The project structure is clear and suitable as a learning reference for understanding the principles of natural language interface database query.
Github:https://github.com/Paulisure/AI-Database-Query-Assistant
Oil tubing: