Spaces:
Runtime error
Runtime error
Add option of switch to gpt-4-turbo
Browse files
app.py
CHANGED
@@ -7,7 +7,14 @@ import requests
|
|
7 |
|
8 |
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
def repo_get_all_employees_from_database():
|
13 |
url = "https://api.airtable.com/v0/appopGmlHujYnd6Vw/Interviewers?maxRecords=100&view=Grid%20view"
|
@@ -76,17 +83,26 @@ def predict(message, history):
|
|
76 |
history_openai_format.append({"role": "user", "content": prompt})
|
77 |
|
78 |
global model
|
|
|
79 |
|
80 |
-
if (
|
81 |
-
model = "
|
82 |
-
|
|
|
|
|
|
|
|
|
83 |
|
84 |
-
if (
|
85 |
-
model =
|
86 |
-
|
|
|
|
|
|
|
87 |
|
88 |
response = client.chat.completions.create(
|
89 |
-
model=
|
|
|
90 |
messages= history_openai_format,
|
91 |
temperature=0,
|
92 |
stream=True)
|
@@ -98,8 +114,6 @@ def predict(message, history):
|
|
98 |
yield partial_message
|
99 |
|
100 |
pre_configured_promt = "For conducting an interview I need 1 employee in given time slot: start time is March 11 2024 2 pm, duration 1 hour"
|
101 |
-
switch_to_gpt3 = "Switch to gpt-3.5"
|
102 |
-
switch_to_gpt4 = "Switch to gpt-4"
|
103 |
|
104 |
description = '''
|
105 |
# AI Interview Team Assistant | Empowered by Godel Technologies AI \n
|
@@ -110,8 +124,16 @@ You can send any regular prompts you wish or pre-configured Chain-of-Thought pro
|
|
110 |
To trigger pre-configured prompt you have to craft a prompt with next structure:
|
111 |
- "{pre_configured_promt}"
|
112 |
\n
|
113 |
-
You can switch between gpt-3.5
|
114 |
-
'''.format(pre_configured_promt=pre_configured_promt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
-
examples = ["Who are you?", "What is your purpose?", switch_to_gpt3, switch_to_gpt4, pre_configured_promt]
|
117 |
gr.ChatInterface(predict, examples=examples, description=description).launch()
|
|
|
7 |
|
8 |
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
9 |
|
10 |
+
switch_to = "Switch to {model}"
|
11 |
+
switched_to = "Switched to: {model}"
|
12 |
+
|
13 |
+
gpt3_turbo = "gpt-3.5-turbo"
|
14 |
+
gpt4 = "gpt-4"
|
15 |
+
gpt4_turbo = "gpt-4-turbo-preview"
|
16 |
+
|
17 |
+
model = gpt3_turbo
|
18 |
|
19 |
def repo_get_all_employees_from_database():
|
20 |
url = "https://api.airtable.com/v0/appopGmlHujYnd6Vw/Interviewers?maxRecords=100&view=Grid%20view"
|
|
|
83 |
history_openai_format.append({"role": "user", "content": prompt})
|
84 |
|
85 |
global model
|
86 |
+
switched = False
|
87 |
|
88 |
+
if (switch_to.format(model=gpt3_turbo).lower() in message.lower()):
|
89 |
+
model = gpt3_turbo"
|
90 |
+
switched = True
|
91 |
+
|
92 |
+
if (switch_to.format(model=gpt4).lower() in message.lower()):
|
93 |
+
model = gpt4
|
94 |
+
switched = True
|
95 |
|
96 |
+
if (switch_to.format(model=gpt4_turbo).lower() in message.lower()):
|
97 |
+
model = gpt4_turbo
|
98 |
+
switched = True
|
99 |
+
|
100 |
+
if (switched):
|
101 |
+
print(switched_to.format(model=model))
|
102 |
|
103 |
response = client.chat.completions.create(
|
104 |
+
# model=model, # gpt-4 and gpt-4-turbo-preview are temporarily disabled to save money
|
105 |
+
model=gpt3_turbo,
|
106 |
messages= history_openai_format,
|
107 |
temperature=0,
|
108 |
stream=True)
|
|
|
114 |
yield partial_message
|
115 |
|
116 |
pre_configured_promt = "For conducting an interview I need 1 employee in given time slot: start time is March 11 2024 2 pm, duration 1 hour"
|
|
|
|
|
117 |
|
118 |
description = '''
|
119 |
# AI Interview Team Assistant | Empowered by Godel Technologies AI \n
|
|
|
124 |
To trigger pre-configured prompt you have to craft a prompt with next structure:
|
125 |
- "{pre_configured_promt}"
|
126 |
\n
|
127 |
+
You can switch between gpt-3.5-turbo | gpt-4 | gpt-4-turbo with prompts listed in "Examples".
|
128 |
+
'''.format(pre_configured_promt=pre_configured_promt)
|
129 |
+
|
130 |
+
examples = [
|
131 |
+
"Who are you?",
|
132 |
+
"What is your purpose?",
|
133 |
+
switch_to.format(model=gpt3_turbo),
|
134 |
+
switch_to.format(model=gpt4),
|
135 |
+
switch_to.format(model=gpt4_turbo),
|
136 |
+
pre_configured_promt
|
137 |
+
]
|
138 |
|
|
|
139 |
gr.ChatInterface(predict, examples=examples, description=description).launch()
|