19 June 2023
Set up your own customised proxy server for LegacyAI with the following steps.
This guide assumes you are using Mac OS and will be hosting the server application on Heroku.
mkdir heroku-proxy-server
cd heroku-proxy-server
python3 -m venv venv
source venv/bin/activate
pip install Flask gunicorn
app.py
with the content from the GitHub repository.API_KEY
within Heroku to your actual OpenAI API key. You can configure this at the dashboard of your Heroku app under Config VarsProcfile
(make sure you save it without any file extension). Add the following content to the Procfile
:web: gunicorn app:app
requirements.txt
file with the following content to specify the project's dependencies:click==8.1.3
Flask==2.1.1
requests==2.26.0
gunicorn==20.1.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.2
Werkzeug==2.2.3
git init
.gitignore
file to exclude unnecessary files from being uploaded:venv/
__pycache__/
*.pyc
*.pyo
*.pyd
*.pyc
*.egg-info/
dist/
build/
*.egg
git add .
git commit -m "Initial commit"
heroku login
your-app-name
with a name for your Heroku proxy server:heroku create your-app-name
git push heroku master
After the deployment, and subsequent build on Heroku is complete, your proxy server will be live on Heroku at:https://your-app-name.herokuapp.com/openai-proxy
After confirming your proxy server URL is correct, you can enter this into LegacyAI and test the functionality of your server.
Logging Server Activity
To log activity on your server, run the following command in your terminal:
heroku logs --app your-app-name --tail
Making Changes
Whenever you make changes to your application, you need to commit and deploy these changes to Heroku. The following commands stage your changes, commits them, and pushes them to the remote repository. Whenever you push any changes your server application will be redeployed on Heroku. Note that this restarts your server which will result in temporary down-time.
git add .
git commit -m ""
git push heroku master
PR Requests
Feel free to add PR requests to the public example server's repository.
Heroku has a maximum request timeout of 30 seconds. This causes issues when the OpenAI API takes longer than 30s to prepare a response. Ideally once you've got your server setup and in a working state you should look at moving it to a different platform.
Post a Comment