Created
November 20, 2021 19:23
-
-
Save trecno/b7c61f1cb65d6c294428f9a2a69a5ba3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
openai.api_key = "API-KEY" | |
conversation = "Human: Hello, who are you?\nAI: I am an AI created by OpenAI. How can I help you today?" | |
print(conversation) | |
i = 1 | |
while (i != 0): | |
question = input("Human: ") | |
conversation += "\nHuman:" + question + "\nAI:" | |
response = openai.Completion.create( | |
engine = "davinci", | |
prompt = conversation, | |
temperature = 0.9, | |
max_tokens = 150, | |
top_p = 1, | |
frequency_penalty = 0, | |
presence_penalty = 0.6, | |
stop = ["\n", " Human:", " AI:"] | |
) | |
answer = response.choices[0].text.strip() | |
conversation += answer | |
print("AI: " + answer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment