-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_migration.py
59 lines (44 loc) · 1.34 KB
/
test_migration.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
49
50
51
52
53
54
55
56
57
# Asking the same question to chatCPT:
def chatGPTrequest(chat_prompt):
engine="gpt-3.5-turbo" #"text-davinci-002"
retries = 3
while retries > 0:
try:
#print("test1")
completion = openai.ChatCompletion.create(
model=engine,
messages = [chat_prompt],
temperature=0.0,
max_tokens=256,
request_timeout=30, #increased with 15
top_p=0.1,
frequency_penalty=0.1,
presence_penalty=0.1,
stop=None
)
#print("test2")
#print(completion['choices'][0]['message']['content'])
generated_text = completion['choices'][0]['message']['content']
#print("test3")
return generated_text
except Exception as e:
if e:
print(e)
print('Timeout error, retrying...')
retries -= 1
wait_time(5)
else:
raise e
print('API is not responding, moving on...')
bad_api = "x"
return bad_api
#Testing
boo_test = False
boo_test = True
if boo_test:
const_prompt = "Give me ten interview questions for the role of project manager"
#const_prompt = const_prompt1
chat_prompt = {'role': 'system', 'content': f'{const_prompt}'}
print("Input: ", chat_prompt)
test = chatGPTrequest(chat_prompt)
print(test)