-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapikeys.py
38 lines (29 loc) · 909 Bytes
/
apikeys.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
import openai
APIKEYS=[
]
GPT4_APIKEYS=[
]
PERSPECTIVE_APIKEYS = [
]
def _check_key(message: str, key='', model='gpt-3.5-turbo') -> str:
"""
model: gpt-3.5-turbo, gpt-3.5-turbo-0301, gpt-4
"""
model="gpt-3.5-turbo"
message_log = [{"role": "user", "content": message}]
openai.api_key = key
completion = openai.ChatCompletion.create(model=model,
messages=message_log,
max_tokens=1)
res = completion.choices[0].message.content
print(f"key:{key}, question: {message} ===> answer: {res}")
return res
if __name__=='__main__':
for key in APIKEYS:
datas = 'hello'
_check_key(datas, key)
print('gpt3.5 keys are fine')
for key in GPT4_APIKEYS:
datas = 'hello'
_check_key(datas, key, model='gpt-4')
print('gpt4 keys are fine')