Spaces:
Runtime error
Runtime error
Fix sharing state of model between users
Browse files
app.py
CHANGED
@@ -14,8 +14,6 @@ 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"
|
21 |
headers = {
|
@@ -77,27 +75,29 @@ def predict(message, history):
|
|
77 |
5. At the end print ids and names of finally selected employees in json format. Please remember that in your output should be maximum {num_employees} employee.
|
78 |
'''.format(data=data, date_time=date_time, num_employees=num_employees)
|
79 |
|
|
|
|
|
80 |
for human, assistant in history:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
history_openai_format.append({"role": "user", "content": human })
|
82 |
history_openai_format.append({"role": "assistant", "content": assistant})
|
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 |
-
|
|
|
99 |
|
100 |
-
if (
|
101 |
print(switched_to.format(model=model))
|
102 |
|
103 |
response = client.chat.completions.create(
|
@@ -107,10 +107,13 @@ def predict(message, history):
|
|
107 |
temperature=0,
|
108 |
stream=True)
|
109 |
|
110 |
-
|
|
|
111 |
for chunk in response:
|
112 |
if chunk.choices[0].delta.content is not None:
|
113 |
partial_message = partial_message + chunk.choices[0].delta.content
|
|
|
|
|
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"
|
|
|
14 |
gpt4 = "gpt-4"
|
15 |
gpt4_turbo = "gpt-4-turbo-preview"
|
16 |
|
|
|
|
|
17 |
def repo_get_all_employees_from_database():
|
18 |
url = "https://api.airtable.com/v0/appopGmlHujYnd6Vw/Interviewers?maxRecords=100&view=Grid%20view"
|
19 |
headers = {
|
|
|
75 |
5. At the end print ids and names of finally selected employees in json format. Please remember that in your output should be maximum {num_employees} employee.
|
76 |
'''.format(data=data, date_time=date_time, num_employees=num_employees)
|
77 |
|
78 |
+
model = gpt3_turbo
|
79 |
+
|
80 |
for human, assistant in history:
|
81 |
+
if (switch_to.format(model=gpt3_turbo).lower() in human.lower()):
|
82 |
+
model = gpt3_turbo
|
83 |
+
if (switch_to.format(model=gpt4).lower() in human.lower()):
|
84 |
+
model = gpt4
|
85 |
+
if (switch_to.format(model=gpt4_turbo).lower() in human.lower()):
|
86 |
+
model = gpt4_turbo
|
87 |
+
|
88 |
history_openai_format.append({"role": "user", "content": human })
|
89 |
history_openai_format.append({"role": "assistant", "content": assistant})
|
|
|
90 |
|
|
|
|
|
|
|
91 |
if (switch_to.format(model=gpt3_turbo).lower() in message.lower()):
|
92 |
model = gpt3_turbo
|
|
|
|
|
93 |
if (switch_to.format(model=gpt4).lower() in message.lower()):
|
94 |
model = gpt4
|
|
|
|
|
95 |
if (switch_to.format(model=gpt4_turbo).lower() in message.lower()):
|
96 |
+
model = gpt4_turbo
|
97 |
+
|
98 |
+
history_openai_format.append({"role": "user", "content": prompt})
|
99 |
|
100 |
+
if (model != gpt3_turbo):
|
101 |
print(switched_to.format(model=model))
|
102 |
|
103 |
response = client.chat.completions.create(
|
|
|
107 |
temperature=0,
|
108 |
stream=True)
|
109 |
|
110 |
+
msg_header = "🤖 {model}:\n\n".format(model=model)
|
111 |
+
partial_message = msg_header
|
112 |
for chunk in response:
|
113 |
if chunk.choices[0].delta.content is not None:
|
114 |
partial_message = partial_message + chunk.choices[0].delta.content
|
115 |
+
pattern = r'({msg_header})+'.format(msg_header=msg_header)
|
116 |
+
partial_message = re.sub(pattern, msg_header, partial_message)
|
117 |
yield partial_message
|
118 |
|
119 |
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"
|