We will be using GPT-3 from OpenAI, a 175 Billion parameter text transformer. Additonally we will be using Python and Streamlit and GitHub to build and host our application. The purpose of this tutorial is to cover the basics in getting a web application powered by GPT-3 up and running.
You can get one by signing up at from beta.openai.com. Once your account is created, you can go to your profile and click the "API Keys" tab or simply click this link OpenAI API Keys.
In this tutorial we will be using a GPT-3 boilerplate that will make our lives easier and allow you to build your own GPT-3 powered application in 20 minutes.
Copy this repository GPT-3-Boilerplate onto your computer and add to your own repositories
1. You need to go into your project folder and create a virtual environment as your choice (I used https://docs.python.org/3/library/venv.html)
2. Activate the virtual environment by running the following commandif you used venv: ./venv/Scripts/activate
3. Install the dependencies by running the following command: pip install -r requirements.txt
4. Run the application by running the following command: streamlit run gpt_app.py
5. The application will be open in a browser window where you need to enter your API key first.
The boilerplate application itself is a Poem generator that will generate a poem based on the input words. We are using the text-davinci-002 model from OpenAI which is defined in the model.py file. Feel free to change the model to any other model that you want to use, and play with the model parameters. For example you can change temperature to 0.9 to generate a more random poem. Feel free to change the whole prompt to any other sentence you want to use.
1. Go to https://share.streamlit.io/ and register your account.
2. Click on New app
3. Choose your Repository, Branch name and the main file path (in our case gpt_app.py)
4. Click Deploy!
Hope you enjoyed this simple tutorial. Hopefully you now have a simple fundation that will allow you to build other type of applications.