3,702 prompts from top AI collections
← Back to Market
[LIVE] [QuantumRishabh/chat-with-database] 2 endpoint(s)
ChatGPT API Proxy/ChatGPT
2,206 characters
Status: [LIVE] Endpoints found: https://python.langchain.com/docs/integrations/chat https://python.langchain.com/docs/integrations/chat/groq/ Source: https://github.com/QuantumRishabh/chat-with-database # Text-to-SQL Query Converter A simple Streamlit app that converts natural language questions into SQL queries using an LLM (via Groq), then runs the generated query against a local SQLite database and displays the results. ## Features - Ask questions about sales data in plain English - LLM converts the question into a SQL query - Query is executed against a local SQLite database - Results are displayed as a table in the browser ## Architecture ![Text-to-SQL architecture: Text in English flows into the LLM (Groq gpt-oss-20b via LangChain), which produces valid SQL, which runs against the SQLite database, producing results rendered back in the Streamlit UI](assets/architecture.png) 1. **Text in English** — the user types a natural-language question into the Streamlit UI. 2. **LLM** — `app.py` wraps the question with the `SALES` table schema and sends it to the Groq-hosted LLM (`langchain-groq`). 3. **Valid SQL** — the LLM's response is cleaned of markdown fences to produce a runnable SQL query. 4. **Database** — the query runs against `sales.db` via `pandas.read_sql_query`. 5. **Results** — the resulting DataFrame (and the generated SQL) is rendered back to the user. ## Project Structure ``` text-to-sql/ ├── app.py # Streamlit app: UI, prompt construction, query execution ├── createdb.py # One-off script to create sales.db and seed sample data ├── requirements.txt # Python dependencies ├── .env # GROQ_API_KEY (not committed) └── sales.db # SQLite database (generated by createdb.py) ``` ## Database Schema **CUSTOMERS** | Column | Type | |---------------|---------| | customer_id | INTEGER (PK) | | customer_name | TEXT | | city | TEXT | | email | TEXT | **PRODUCTS** | Column | Type | |---------------|---------| | product_id | INTEGER (PK) | | product_name | TEXT | | category | TEXT | | price | REAL |
Download .txt