Skip to content

Instantly share code, notes, and snippets.

@JustinStitt
Created April 9, 2023 03:40
Show Gist options
  • Save JustinStitt/b2606e5e1dc210605c22beb067217a07 to your computer and use it in GitHub Desktop.
Save JustinStitt/b2606e5e1dc210605c22beb067217a07 to your computer and use it in GitHub Desktop.
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