- Introduction
- Install dependencies
- Environment variables
- Start Docker containers
- Create a test database
- Run Vanna SQL Agent training
- Start the Solara SQL Chatbot
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 prompts.
Create a new python virtual environment (venv):
python -m venv .venv
Activate the venv:
# On Linux
source .venv/bin/activate
# On Windows using CMD
.venv\Scripts\activate
# On Windows using Git Bash
source .venv/Scripts/activate
Install python dependencies:
pip install -r requirements.txt
Create 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_API_URL='http://localhost:6333'
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'
Start postgresql
and qdrant
containers, and create sales_db
PostgreSQL database:
docker-compose --env-file .env up -d
The python script utils/data_gen.py
will create customer
and purchase
tables in the sales_db
database, and finally fill the tables with random data.
python utils/data_gen.py
Vanna SQL Agent should be trained only once:
python utils/vanna_train.py
Embed the Solara GUI into a FastAPI app:
SOLARA_APP=gui/sol.py uvicorn app:app
The app will be available at http://localhost:8000/solara/