gpt4free/testing/openaihosted_test.py
2023-04-28 16:36:53 +08:00

15 lines
443 B
Python

import openaihosted
messages = [{"role": "system", "content": "You are a helpful assistant."}]
while True:
question = input("Question: ")
if question == "!stop":
break
messages.append({"role": "user", "content": question})
request = openaihosted.Completion.create(messages=messages)
response = request["responses"]
messages.append({"role": "assistant", "content": response})
print(f"Answer: {response}")