Created
May 20, 2023 13:33
-
-
Save anna-geller/a165c040dbb57f041b1162de104d69bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openai | |
import os | |
from dotenv import load_dotenv, find_dotenv | |
load_dotenv(find_dotenv()) | |
openai.api_key = os.getenv("OPENAI_API_KEY") | |
def get_completion(prompt, model="gpt-4"): | |
messages = [{"role": "user", "content": prompt}] | |
response = openai.ChatCompletion.create( | |
model=model, | |
messages=messages, | |
temperature=0.9, | |
) | |
return response.choices[0].message["content"] | |
instructions = f""" | |
Write an SMS to my mum, which lives far away from me. | |
Tell her I'm fine and ask her how she is doing. | |
Say something nice to her in a concise way. | |
The greeting should be very short like "Hi mum!". | |
Don't say that you're checking in - get to the point. | |
The message should be between 80 and 160 characters long. | |
Sign the message at the end with "Anna". | |
""" | |
message = get_completion(instructions) | |
print(message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment