Skip to content

Latest commit

 

History

History
75 lines (50 loc) · 3.04 KB

README.md

File metadata and controls

75 lines (50 loc) · 3.04 KB

Storytime Backend

This is the backend service that coordinates the websocket connections between the client and the AI services.

Tools Used

  1. Livepeer Text-to-Image
  2. OpenAI ChatGPT

Requirements

  1. Node.js 21 or later, v21.7.1 used for development — older versions may work, but are untested
  2. WebSockets need to use SSL (wss://) to operate safely in production. The author recommends using letsencrypt.org

Installation

Local Development

  1. Clone this repository to a local directory of your choice
  2. Navigate to the root of the project directory in the terminal emulator of your choice
  3. Make a copy of .env.example -> .env.local and update it with the required API keys
  4. Run the npm install command to install the required application dependencies
  5. Run the npm run dev command to set up watchers for Typescript source and the compiled server

For Production Deployments

  1. Generate your SSL certificate using LetsEncrypt *
  2. Rename fullchain.pem to server.crt
  3. Rename privkey.pem to server.key
  4. Place both of these files into the root of this project under /certs/
  5. You may consider using a reverse proxy such as nginx, haproxy, etc.
  6. You may also consider a strategy for keeping the app running, such as pm2

* Skip this step if you already have a certificate, or a preferred method of generation

API Integrations

This application integrates several innovative third-party APIs to achieve the final result. You will need to ensure that you have made the necessary modifications to the .env file as mentioned previously. More information below:

Livepeer

Livepeer provides us with a Stable Diffusion text-to-image API API built on their distributed protocol.

For this integration, we use the following environment variables:

  1. LIVEPEER_TEXT_TO_IMAGE_ENDPOINT
  2. LIVEPEER_BEARER_TOKEN *
  3. LIVEPEER_SD_MODEL
  4. LIVEPEER_SD_GUIDANCE
  5. LIVEPEER_SD_NEGATIVE_PROMPT
  6. LIVEPEER_SD_IMAGE_SIZE
  7. LIVEPEER_SD_IMAGE_COUNT

* Currently not required in beta, but you should hop in the Livepeer Discord for support

OpenAI

We use OpenAI for their moderation and chat completion APIs. You will need an OpenAI API Key and available credits on your account.

For this integration, we use the following environment variables:

  1. OPENAI_API_KEY
  2. OPENAI_TOP_P *
  3. OPENAI_TEMPERATURE *
  4. OPENAI_FREQUENCY_PENALTY *
  5. OPENAI_PRESENCE_PENALTY *
  6. OPENAI_MAX_TOKENS *
  7. OPENAI_MODEL *

* Sensible default provided in .env.example

TODO

  • Currently, the backend API lacks authentication
  • Database replication via Fireproof