GithubHelp home page GithubHelp logo

djkarma / langchain-sql-agent-bootstrap Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cogitovirus/langchain-sql-agent-bootstrap

0.0 0.0 0.0 2.28 MB

Langchain SQL Agent Boostrap application. Flask on the backend, React on the front.

Home Page: https://cogitovirus.com/posts/20230402-gpt-4-langchain-agent-bootstrap/

License: MIT License

Python 47.04% TypeScript 42.00% CSS 3.79% HTML 5.90% Dockerfile 1.27%

langchain-sql-agent-bootstrap's Introduction

Langchain SQL Agent Bootstap

This is a simple App for testing LLM to SQL commands on a sqlite database using Langchain SQL Agent. The repo comes with a setup script that loads a sqlite database with some sample data.

This repo is intended to be a starter for Langchain and also a starter for programming with co-pilot GPT-4. The scope is small enough that you can even get by with copying/pasting whole clases to GPT-4 and asking for explanations or improvemnts to the code. There's a single important TODO item that is not and will not be ever completed, which is to implement the file upload functionality in the UI. The backend is already setup to handle file uploads (csv). If you're interested you could probably also:

  • clean the ouput of the agent after each execution
  • add a auto-refresh or a refresh button to the tables

Backend has several endpoints:

  • /api/v1/tables - returns a list of tables in the database
  • /api/v1/tables/<table_name> - returns a list of columns in the table
  • /api/v1/run-command - takes a json payload with the command to execute and returns the results via a websocket
  • /api/v1/upload - takes a csv file and loads it into the database

run-command is where all the fun is happening with the langchain sql agent.

Example 1 Exampe 2

Running locally

Pre-requisites

Backend was setup with Python 3.10.10

Frontend was setup with Node 18.15.0

Experience may vary with other versions

You have to have an open-api-api-key to use the langchain sql agent.

Copy the .env.example file to .env and add your key to the OPENAI_API_KEY variable. You can also change the model which is used to make predictions. In the time of writing, gpt-4 is in closed beta, so the backend might not work if you select that model.

Backend

Create virtual environment (only need to do this once)

python3 -m venv data-whisperer-backend/myenv

activate virtual environment

source data-whisperer-backend/myenv/bin/activate
# install dependencies
pip install -r data-whisperer-backend/requirements.txt

seed the database

python data-whisperer-backend/setup/create_and_seed_db.py

finally, run the backend

python data-whisperer-backend/run.py

Frontend

cd data-whisperer-frontend/
npm install # only need to do this once
npm start

Teardown

# deactivate virtual environment after you are done
deactivate

langchain-sql-agent-bootstrap's People

Contributors

cogitovirus avatar jwszolek avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.