Spaces:
Build error
Build error
praeclarumjj3
commited on
Commit
•
f598a68
1
Parent(s):
cfcddc7
Update app.py
Browse files
app.py
CHANGED
@@ -166,27 +166,27 @@ def http_bot(state, model_selector, temperature, top_p, max_new_tokens, request:
|
|
166 |
yield (state, state.to_gradio_chatbot()) + (disable_btn,) * 5
|
167 |
|
168 |
|
169 |
-
|
170 |
# Stream output
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
|
191 |
state.messages[-1][-1] = state.messages[-1][-1][:-1]
|
192 |
yield (state, state.to_gradio_chatbot()) + (enable_btn,) * 5
|
@@ -233,7 +233,7 @@ def build_demo(embed_mode):
|
|
233 |
with gr.Column(scale=3):
|
234 |
with gr.Row(elem_id="model_selector_row"):
|
235 |
model_selector = gr.Dropdown(
|
236 |
-
choices=models,
|
237 |
value=models[0]+"-4bit" if len(models) > 0 else "",
|
238 |
interactive=True,
|
239 |
show_label=False,
|
|
|
166 |
yield (state, state.to_gradio_chatbot()) + (disable_btn,) * 5
|
167 |
|
168 |
|
169 |
+
try:
|
170 |
# Stream output
|
171 |
+
response = chat.generate_stream_gate(pload)
|
172 |
+
for chunk in response:
|
173 |
+
if chunk:
|
174 |
+
data = json.loads(chunk.decode())
|
175 |
+
if data["error_code"] == 0:
|
176 |
+
output = data["text"][len(prompt):].strip()
|
177 |
+
state.messages[-1][-1] = output + "▌"
|
178 |
+
yield (state, state.to_gradio_chatbot()) + (disable_btn,) * 5
|
179 |
+
else:
|
180 |
+
output = data["text"] + f" (error_code: {data['error_code']})"
|
181 |
+
state.messages[-1][-1] = output
|
182 |
+
yield (state, state.to_gradio_chatbot()) + (disable_btn, disable_btn, disable_btn, enable_btn, enable_btn)
|
183 |
+
return
|
184 |
+
time.sleep(0.03)
|
185 |
+
except Exception:
|
186 |
+
gr.Warning(server_error_msg)
|
187 |
+
state.messages[-1][-1] = server_error_msg
|
188 |
+
yield (state, state.to_gradio_chatbot()) + (disable_btn, disable_btn, disable_btn, enable_btn, enable_btn)
|
189 |
+
return
|
190 |
|
191 |
state.messages[-1][-1] = state.messages[-1][-1][:-1]
|
192 |
yield (state, state.to_gradio_chatbot()) + (enable_btn,) * 5
|
|
|
233 |
with gr.Column(scale=3):
|
234 |
with gr.Row(elem_id="model_selector_row"):
|
235 |
model_selector = gr.Dropdown(
|
236 |
+
choices=[model + "-4bit" for model in models],
|
237 |
value=models[0]+"-4bit" if len(models) > 0 else "",
|
238 |
interactive=True,
|
239 |
show_label=False,
|