Skip to content

dinyad-prog00/llm--text2sql-chatbot-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

16ed00c · Aug 8, 2024

History

4 Commits
Aug 8, 2024
Jul 14, 2024
Jul 14, 2024
Aug 8, 2024
Jul 14, 2024

Repository files navigation

LLM Text2SQL Project

Overview

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.

Getting Started

Option 1: Using LLM API from Google or OpenAI

Prerequisites

  • Python 3.7+

Installation

  1. Clone the repository:

    git clone https://github.com/dinyad-prog00/llm--text2sql-chatbot-api.git
  2. Create and activate a virtual environment:

    python -m venv text2sql_venv
    source text2sql_venv/bin/activate   # On Windows, use `text2sql_venv\Scripts\activate`
  3. Install the dependencies:

    pip install -r requirements.txt
  4. Set up environment variables:

    Create a .env file in the root directory and add the following:

  5. Place your Google Cloud Service Account Key (Only if using BigQuery):

    Paste in JSON file and place it in the root directory .keys/.

  6. 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 at http://localhost:8000/docs

Option 2: Running Open Source Model on Conda Env

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/dinyad-prog00/llm--text2sql-chatbot-api.git
  2. 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
  3. Install the dependencies:

    pip install -r requirements.txt
  4. Set up environment variables:

    Create a .env file in the root directory and add the following:

    • MODEL_TYPE, type can be pipable or chatdb
    • HF_TOKEN, User Access Token to authenticate to the HuggingFace Hub to pull open source model (Get my HF_TOKEN)
  5. Place your Google Cloud Service Account Key (Only if using BigQuery): Paste in JSON file and place it in the root directory .keys/.

  6. 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 at http://localhost:8000/docs