-
Notifications
You must be signed in to change notification settings - Fork 2
/
newassistant.py
68 lines (52 loc) · 1.53 KB
/
newassistant.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
65
66
67
#creates a new assistant
import config
import openai
import os
import time
import shutil
openai.api_key = config.openaiapikey
print("Enter the assistants Name")
gptname = input().lower()
print("Enter the instructions for the Assistant. How they should behave, speak etc.")
gptinstruction= input()
print("In which language will you speak to this assistant? e.g. en-US")
language = input()
print("Enter the ElevenLabs voice name that the assistant should use")
voiceid = input()
print("Do you want to use the gpt-4-turbo preview or gpt-3.5-turbo? Enter 4 or 3. ")
modelnumber = input()
if modelnumber == "3" :
gptmodel = "gpt-3.5-turbo-1106"
elif modelnumber == "4":
gptmodel = "gpt-4-1106-preview"
else:
print("Neither 3 or 4")
time.sleep(2)
quit()
assistant = openai.beta.assistants.create(
name=gptname,
instructions=gptinstruction,
model=gptmodel
)
configfile = gptname + "_config" + ".py"
assistantfile = gptname + ".py"
src_dir = os.getcwd()
dest_dir = src_dir + "\\" + assistantfile
shutil.copy('undefassistant.py', dest_dir)
#append assistant specifics to config file
with open(configfile, "w") as file:
l1 = "\nassistantid = "
l2 = '"'
l3 = assistant.id
l4 = '"\n'
l5 = "voiceid = "
l6 = '"'
l7 = voiceid
l8 = '"\n'
l9 = "language = "
l10 = '"'
l11 = language
l12 = '"'
file.writelines([l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12])
file.close
print(f"The Assistant has been created, you can now create a Thread with it by executing {assistantfile}")