This project is a proof-of-concept demonstrating how to create a simple SQL Chatbot using Solara for GUI development, FastAPI as the backend framework, Azure OpenAI API as the language model, Qdrant Vector Database for managing embeddings, PostgreSQL for data storage, and Vanna AI SQL Agent for generating SQL queries from natural language inputs.
- Install dependencies
- Environment variables
- Start Docker containers
- Create a test database
- Run Vanna SQL Agent training
- Start the Solara SQL Chatbot
Create a new Python virtual environment (venv):
python -m venv .venvActivate the venv:
# On Linux
source .venv/bin/activate# On Windows using CMD
.venv\Scripts\activate# On Windows using Git Bash
source .venv/Scripts/activateInstall Python dependencies:
pip install -r requirements.txtCreate a .env file and add the environment variables:
# PostgreSQL
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=sales_db
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
# Qdrant
QDRANT__SERVICE__API_KEY=api-key-readwrite
QDRANT__SERVICE__READ_ONLY_API_KEY=api-key-readonly
# Azure OpenAI
AZURE_OPENAI_MODEL_DEPLOYMENT='model-deployment-name'
AZURE_OPENAI_ENDPOINT='openai-endpoint'
AZURE_OPENAI_API_VERSION='openai-api-version'docker-compose up -dsales_db PostgreSQL database will be created
The python script db/utils/data_gen.py will create customerand purchase tables in sales_db database, and finally fill the tables with random data.
python db/utils/data_gen.pyVanna SQL Agent should be trained only once:
python db/vanna/vanna_train.pyOption 1: Run the standalone Solara app:
solara run gui/sol.pyThe app will be available at http://localhost:8765
Option 2: Embed the Solara GUI into a FastAPI app:
SOLARA_APP=gui/sol.py uvicorn app:appThe app will be available at http://localhost:8000/solara/

