Text2SQL is an advanced project designed to convert natural language queries into SQL queries. This application leverages large language models (LLMs) to interpret user queries and interact with a database to fetch and return the desired data. The project is built using FastAPI, providing a robust and scalable server to handle the processing of queries.
- Python 3.7+
-
Clone the repository:
git clone https://github.com/dinyad-prog00/llm--text2sql-chatbot-api.git
-
Create and activate a virtual environment:
python -m venv text2sql_venv source text2sql_venv/bin/activate # On Windows, use `text2sql_venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Set up environment variables:
Create a
.env
file in the root directory and add the following:- MODEL_TYPE, type can be
google
oropenai
- GOOGLE_API_KEY if using Google (Get my GOOGLE_API_KEY, use your perso gmail)
- OPENAI_API_KEY if using OpenAI (Get my OPENAI_API_KEY)
- MODEL_TYPE, type can be
-
Place your Google Cloud Service Account Key (Only if using BigQuery):
Paste in JSON file and place it in the root directory
.keys/
. -
Running the Server:
Start the FastAPI server using FastAPI CLI (or Uvicorn):
./text2sql_venv/bin/fastapi dev src/server.py
The server will be accessible at
http://localhost:8000
. The Swagger docs athttp://localhost:8000/docs
- Python 3.7+
- Conda CLI
- HuggingFace Account
- Sufficient RAM or GPU memory depending on the size of the model
-
Clone the repository:
git clone https://github.com/dinyad-prog00/llm--text2sql-chatbot-api.git
-
Create and activate a Conda environment: Tensorflow
conda create -n text2sql_venv tensorflow conda activate text2sql_venv
Or
conda create -n text2sql_venv tensorflow-gpu conda activate text2sql_venv
-
Install the dependencies:
pip install -r requirements.txt
-
Set up environment variables:
Create a
.env
file in the root directory and add the following:- MODEL_TYPE, type can be
pipable
orchatdb
- HF_TOKEN, User Access Token to authenticate to the HuggingFace Hub to pull open source model (Get my HF_TOKEN)
- MODEL_TYPE, type can be
-
Place your Google Cloud Service Account Key (Only if using BigQuery): Paste in JSON file and place it in the root directory
.keys/
. -
Running the Server:
Start the FastAPI server using FastAPI CLI (or Uvicorn):
./text2sql_venv/bin/fastapi dev src/server.py
The server will be accessible at
http://localhost:8000
. The Swagger docs athttp://localhost:8000/docs