-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
52 lines (38 loc) · 1.23 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import openai
import config
openai.api_key = config.openai_api_key
print("")
print('Type when prompted by >>>, enter in \'exit\' to exit the program')
# # list engines
# engines = openai.Engine.list()who am i
# # print the first engine's id
# print(engines.data[0].id)
# create a completion, the following loop runs the whole program
'''
LATEST MODEL MAX REQUEST TRAINING DATA
text-davinci-002 4,000 tokens Up to Jun 2021
text-curie-001 2,048 tokens Up to Oct 2019
text-babbage-001 2,048 tokens Up to Oct 2019
text-ada-001 2,048 tokens Up to Oct 2019
'''
loop_var = True
while loop_var == True:
user_input = input('>>>')
completion = openai.Completion.create(
engine="text-davinci-002",
prompt=user_input,
temperature=0.5,
top_p=1,
max_tokens=256,
frequency_penalty=0,
presence_penalty=0)
if user_input == 'exit':
loop_var == False
break
else:
# print the completion
print('-------------------------------------------------')
print(completion.choices[0].text)
print(" ")
print('-------------------------------------------------')
print('-----------------------END--------------------------')