Created
April 9, 2023 03:40
-
-
Save JustinStitt/b2606e5e1dc210605c22beb067217a07 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 os | |
import openai | |
openai.api_key = "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" | |
# user, system, assistant | |
prompt = """ | |
You are a vacation planner. The user will provide locations and prefered | |
climates. Then you will give them great vacation spots/activities. | |
If the user doesn't mention locations/vactions/climates or anything similar please | |
respond with "I am a vacation planner. Ask a different robot, nerd." | |
""" | |
messages = [{"role": "system", "content": prompt}] | |
def write_message(message: str): | |
messages.append({"role": "user", "content": message}) | |
response = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=messages) | |
gpt_response = response["choices"][0]["message"]["content"] | |
messages.append({"role": "assistant", "content": gpt_response}) | |
print(gpt_response, flush=True) | |
inp = "" | |
while 1: | |
inp = input("> ") | |
if inp == "exit": | |
exit(0) | |
write_message(inp.rstrip()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment