My own version of OpenAI API Quickstart - Python example app
This is an example of documentary film seeker that utilizes OpenAI's GPT-3.5 Turbo model to assist users in finding documentary films made by BBC or National Geographic based on their input queries. The app acts as an intelligent assistant that can understand user requests and provides relevant responses in both Chinese and English. This is also for my little boy.
It is based on the App used in the OpenAI API quickstart tutorial. It uses the Flask web framework. Check out the tutorial or follow the instructions below to get set up.
- OS: Mac 12.6.8
- Python: 3.11.4 / Flask
- AnaConda: 4.12
-
If you don’t have Python installed, install it from here.
-
Clone this repo or the original.
-
Navigate into the project directory:
$ cd openai-quickstart-python
-
Create a new virtual environment with AnaConda, e.g. named
OpenAI
. Activate it:(base) mhoehn1:~ kikitamoon$ conda activate OpenAI (OpenAI) mhoehn1:~ kikitamoon$ conda env list # conda environments: # base /Users/kikitamoon/opt/anaconda3 OpenAI * /Users/kikitamoon/opt/anaconda3/envs/OpenAI
-
Install the requirements:
$ pip install -r requirements.txt
-
Make a copy of the example environment variables file:
$ cp .env.example .env
-
Add your API key to the newly created
.env
file.Alternatively, set System Env Varaibles if you're using Windows. to support the code:
openai.api_key = os.getenv("OPENAI_API_KEY")
-
Run the app:
$ flask run
You should now be able to access the app at http://localhost:5000! For the full context behind this example app, check out the tutorial.
See the workflow to understand the necessary steps and quickly get started: