FastAPI Quikchat Starter

This project is an example of integrating the QuikChatJS widget with a Python FastAPI webbackend. The application includes endpoints for handling both completions and streaming completions from an API like OpenAI's GPT, as well as a chat widget that can be embedded in other applications.

Project Structure

/examples/FastApi-Quikchat-Starter
|--- app.py                      # Main FastAPI application
|--- static/
|   |-- index.html              # Main chat page
|   |-- widget.html             # Embeddable chat widget page
|   |-- quikchat.css            # QuikChatJS CSS
|   |-- quikchat.umd.min.js     # QuikChatJS JavaScript
|-- .env                        # Environment variables
|-- README.md                   # This documentation
|-- requirements.txt            # Python dependencies

Setup

Prerequisites

Installation

  1. Install dependencies:

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

    Create a .env file in the root of the project with the following content:

    OPENAI_BASE_URL=https://api.openai.com/v1
    OPENAI_API_KEY=your_openai_api_key_here
    

    Replace your_openai_api_key_here with your actual OpenAI API key.

Running the Application

To start the FastAPI server, run:

python main.py

The server will start on http://127.0.0.1:8000.

Then go to your browser and open up http://127.0.0.1:8000.

Endpoints

Example Usage

Development

While the server is running, any changes you make to the main.py or static files will be automatically reloaded.

Notes