Skip to content

shamilnabiyev/solara-sql-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solara SQL Chatbot

Table of Contents

Introduction

Chatbot GUI
Fig.1: Solara Chatbot GUI

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.

Chatbot GUI
Fig.2: Components Diagram

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

Start postgresql and qdrant containers, and create sales_db PostgreSQL database:

docker-compose --env-file .env up -d

Create a test database

The python script utils/data_gen.py will create customerand purchase tables in the sales_db database, and finally fill the tables with random data.

python utils/data_gen.py

Run Vanna SQL Agent training

Vanna SQL Agent should be trained only once:

python utils/vanna_train.py

Start the Solara SQL Chatbot

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

Topics

Resources

Stars

Watchers

Forks

Languages