On running the code in Jupiter Notebook,
Code:
Base function:
def get_completion(prompt, model=“gpt-3.5-turbo”): # Andrew mentioned that the prompt/ completion paradigm is preferable for this class
messages = [{“role”: “user”, “content”: prompt}]
response = openai.ChatCompletion.create(
model=model,
messages=messages,
temperature=0, # this is the degree of randomness of the model’s output
)
return response.choices[0].message[“content”]
prompt = f"“”
Your task is to generate a short summary of a product
review from an ecommerce site.
Summarize the review below, delimited by triple
backticks, in at most 30 words.
Review: {prod_review}
“”"
response = get_completion(prompt)
print(response)