by Devin Yang
(This article was automatically translated.)

Published - 1 year ago ( Updated - 1 year ago )

If you log in to the openai website, you can see the official teaching instructions here
https://beta.openai.com/docs/quickstart/build-your-application

API KEY application is on this page There is a button below

+ Create new secret key

This article teaches you to use Docker to run the official OpenAI execution environment.

official version:

git clone https://github.com/openai/openai-quickstart-python.git
cd openai-quickstart-python
cp.env.example.env
python -m venv venv
.venv/bin/activate
pip install -r requirements.txt
flask run

But if you just want to try it out during the free period, you can also use docker to quickly install it on your own MacOS.

git clone https://github.com/openai/openai-quickstart-python.git
cd openai-quickstart-python
# One more step, run Docker first
docker run --rm -v $(pwd):/app -w /app -p 5001:5000 -ti python:3.10.9 bash
#Skip the installation of venv, run the container without venv, install it directly
pip install -r requirements.txt
#The container cannot listen to 127.0.0.1, so there is one more parameter --host
flask run --host 0.0.0.0

After completion, remember to set your Token in .env, and you can use it.

FLASK_APP=app
FLASK_ENV=development
OPENAI_API_KEY=

Because the AirPlay receiver will consume 5000 and 7000, it must avoid conflicts, so I changed the Port on the host side to 5001
for use Open the screen in the browser, and you can test it. Remember that the Docker port is opened at 5001.

http://127.0.0.1:5001

If there is no problem, remember to commit as image, so you don’t have to reinstall all the time. The garbled code here is the hostname of the container, please don’t copy it My.

docker commit 520ad08c41e2 openai

Leave the container and restart with our commit image

 docker run --rm - v $(pwd):/app -w /app -p 5001:5000 -ti openai flask \
 run --host 0.0.0.0

You should see the following screen:

$docker run --rm -v $(pwd):/app -w /app -p 5001:5000 -ti openai flask\
 run --host 0.0.0.0
 * Serving Flask app 'app' (lazy loading)
 * Environment: development
 * Debug mode: on
 * Running on all addresses.
   WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://172.17.0.2:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 130-035-104

Tags: openai flax docker

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


docker,polymer,seo

Solving Polymer SEO Problems with Rendertron (Polymer Summit 2017)

The video below the article introduces how to use rendertron to solve Polymer SEO optimization problems. In the source of my fork, it has been adjusted to support the Chinese environment. And also added the API interface of pdf, which can also be used to convert pdf.

docker

Devin Yang's Notes for Beginners with Docker

These are my notes when I first learned Docker. It is a bit rough and I have adjusted it a bit. But I think for Docker beginners, it should be able to provide some preliminary concepts, Welcome to refer to it.

docker,Synology

How to modify the logging driver of Docker on Synolog NAS

On my Synolog Nas, a strange logging driver named db is running by default, how to modify it to a normal json-file? In Synolog's Nas, his Daemon config file is special, and it is placed in the /var/packages/Docker/etc/ directory. Called dockerd.json.