Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hdahle authored Jul 3, 2023
1 parent 59f4717 commit addc38f
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
# OpenAI Playground

Frontend application inspired by
https://scrimba.com/learn/buildaiapps
[Build AI Apps with ChatGPT, Dall-E and GPT-4](https://scrimba.com/learn/buildaiapps)

Completely rewritten to remove dependencies on
The frontend is a super-simple HTML/CSS/JS app which uses the [OpenAI API](https://platform.openai.com/docs/api-reference)

The Freecodecamp/Scrimba course on OpenAI was quite useful, but I decided to do some changes to my implementation. I removed the dependencies on
- Netlify
- OpenAI node.js module
- Vite for bundling of js

In order to make front-end responsive, using w3.css instead of home-brew Scrimba CSS
Also, I changed the CSS to be responsive, using [W3Schools W3.CSS framework](https://www.w3schools.com/w3css/defaulT.asp)

## Architecture

````
OpenAI API Key
|
V
|--------------------| |---------------| |------------|
| | --> POST request --> | API Proxy | --> POST Request --> | |
| Client HTML/JS app | | in | | OpenAI API |
| | <---- Reply <----- | AWS/Lightsail | <---- Reply <----- | |
|--------------------| |---------------| |------------|
````


## Random comments

- Get an API key from OpenAPI
- You need Get an API key from OpenAPI
- The Youtube/Scrimba project this is based on used Vite for deployment
- While Vite worked well for hosting on localhost, I could not get it to build an app correctly for remote deployment
- It seemed better to remove any unnecessary dependencies and avoid having to bundle
- Since the original App used the OpenAI node.js module, Vite was used to bundle the JS-app
- Removing the OpenAI node.js module obviated the need for bundling

For 'production' deployment, the original Scrimba app used Netlify in order to hide the OpenAI key in a serverless function on Netlify, so the front-end app would call Netlify which in turn would call OpenAI API, instead of having the front-end app call OpenAI API directly which would expose the key

Expand All @@ -31,3 +48,9 @@ This app uses a similar approach:
- My original CSV-formatted training file is in ```data```
- I used openai CLI to convert it to JSONL format
- The JSONL-file is then fine tuned and a model is created. This can take minutes, hours, days

## Lessons learned

Using the "Completions" API endpoint is actually the wrong API endpoint for this type of application.

Apparently, "Embeddings" is a better approach.

0 comments on commit addc38f

Please sign in to comment.