Skip to content

shamilnabi/solara-sql-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 inputs.

Chatbot GUI
Fig.1: Solara Chatbot GUI

Chatbot GUI
Fig.2: Components Diagram

Table of Contents

Install dependencies

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

Environment variables

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__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 Docker containers

docker-compose up -d

sales_db PostgreSQL database will be created

Create a test database

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.py

Run Vanna SQL Agent training

Vanna SQL Agent should be trained only once:

python db/vanna/vanna_train.py

Start the Solara SQL Chatbot

Option 1: Run the standalone Solara app:

solara run gui/sol.py

The 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:app

The app will be available at http://localhost:8000/solara/

About

Solara SQL Chatbot using Azure OpenAI model and Vanna AI SQL Agent

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages