-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaskgpt.py
64 lines (49 loc) · 1.41 KB
/
askgpt.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
58
59
60
61
62
63
64
import openai
import webbrowser
def askGPT(gpt_prompt):
"""
Args:
gpt_prompt: User questions, text prompts etc.
Returns: the response from gpt - the default model is davinci-003
"""
tokenlimit = 1200
response = openai.Completion.create(
model="text-davinci-003",
prompt=gpt_prompt,
temperature=0.7,
max_tokens=tokenlimit,
top_p=1,
frequency_penalty=0.0,
presence_penalty=0.0
# stop=["\n"]
)
return (response['choices'][0]['text'])
def askdalle(prompt):
response = openai.Image.create(
prompt=prompt,
n=1,
size="1024x1024"
)
dalleurl = response['data'][0]['url']
webbrowser.open(dalleurl, new=0, autoraise=True)
# storetopath = r"D:\OneDrive\DALLEImageStorage"
return (response['data'][0]['url'])
def chatwithGPT(gpt_prompt):
"""
This is a new development for chatting with the latest model, 3.5
Args:
gpt_prompt: User questions, text prompts etc.
Returns: the response from gpt - the default model is davinci-003
"""
tokenlimit = 1200
response = openai.Completion.create(
model="text-davinci-003",
prompt=gpt_prompt,
temperature=0.7,
max_tokens=tokenlimit,
top_p=1,
frequency_penalty=0.0,
presence_penalty=0.0
# stop=["\n"]
)
return (response['choices'][0]['text'])