ViditOstwal/TEXT-2-SQL-CHATBOT
0
Pharma Data QA — Text-to-SQL Chatbot
About
This application is a Text-to-SQL Chatbot designed to answer natural language questions about pharmaceutical sales and prescription data. It leverages a Large Language Model (LLM) to translate user queries into SQL, executes them against a local SQLite database (pharma_data.db), and presents the results in an interactive interface.
Key features:
- Natural Language Querying: Ask questions like "Which territory has the highest prescription volume?" without knowing SQL.
- Transparent Logic: View the generated SQL, the raw result, and a natural language explanation of the answer.
- Interactive UI: Built with Gradio for a user-friendly experience.
Setup
This project uses uv for fast Python package management.
Prerequisites
- Python 3.11 or higher
- uv installed
Installation
- Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh- Clone the repository Navigate to the project directory.
- Sync dependencies: This command will create a virtual environment and install all dependencies defined in
pyproject.toml.
uv sync- Set up environment variables:
export OPENAI_API_KEY="your_openai_api_key_here"Running the Application
To run the Gradio application:
uv run app.pyThe application will launch in your browser (typically at http://127.0.0.1:7860).
