OpenAI Simple React Chatbot & FastAPI

Description

React frontend with Python fastapi backend for rapid testing, prompt engineering, and task automation at low cost

Run in Docker

  1. Copy example .env file in /backend and set OPENAI_API_KEY
   # Linux
   $ cp .env.example .env
  1. From the root folder run
   $ docker-compose up --build

Local Instructions

  1. Install Python
  2. Clone This Repo
  3. Get yarn (Mac: https://tecadmin.net/install-yarn-macos/)
$ brew install yarn 

Backend

  1. Build python venv
   # Linux
   $ python -m venv venv
   $ . venv/bin/activate
  1. Install requirements.txt
   $ pip install -r requirements.txt
  1. Copy example .env file and set OPENAI_API_KEY
   # Linux
   $ cp .env.example .env
  1. Launch fastapi
   $uvicorn main:app
  1. Link for API testing
   http://127.0.0.1:8000/docs 

Frontend

  1. Launch seperate terminal
  2. Navigate to frontend and launch react
   $yarn start

Reference


Frontend: https://github.com/FredrikOseberg/chatbot-tutorial

Backend: https://github.com/oikosohn/openai-quickstart-fastapi