Loading...

Postulate is the best way to take and share notes for classes, research, and other learning.

More info

How to Make GPT-3 Requests in Python

Profile picture of Samson ZhangSamson Zhang
Mar 11, 2021Last updated Mar 11, 20211 min read

For a software project I've been playing around with GPT-3 lately. Using a friend's API key, here's how I set up a connection to the GPT-3 API and made requests using a Jupyter notebook in Python, following this YouTube tutorial to get started.

1. Install openai

!pip install openai import openai

2. Bring in gpt library

From this GitHub repo, download api/gpt.py and upload it to the directory of your notebook. Now import:

from gpt_custom_lib import GPT from gpt_custom_lib import Example

3. Set everything up

tokens = 0 openai.api_key = [TOKEN GIVEN TO ME BY LUKE] gpt = GPT(engine="davinci", temperature=0.5, max_tokens=100)

4. Add examples

gpt.add_example(Example("[INPUT]", "[OUTPUT]"))

5. Get output

output = gpt.submit_request("[PROMPT]") output.choices[0].text


Comments (loading...)

Sign in to comment

Mormon's property management stuff

Software contracting project with Mormon Redd