-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_gpt_4.py
41 lines (32 loc) · 834 Bytes
/
test_gpt_4.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
import openai
import requests
import random
import re
import pickle
from pw import OPEN_AI_API_KEY
# Set up the OpenAI API client
openai.api_key = OPEN_AI_API_KEY
def main():
prompt = "What is the meaning of life?"
# Set the parameters for the OpenAI API request
params = {
'model': 'gpt-4',
'prompt': prompt,
'temperature': 0.9,
# 'frequency_penalty': 1.99,
# 'presence_penalty': 1,
'max_tokens': 70,
'n': 1,
# 'stop': '\n',
}
# Call the OpenAI API to generate the tweet
print("Making a request...")
response = openai.ChatCompletion.create(**params)
for r in response.choices:
print(r)
tweet = response.choices[0].text.strip()
return tweet
if __name__ == "__main__":
main()
print("exiting.")
exit(0)