Spaces:
Build error
Build error
praeclarumjj3
commited on
Commit
•
6e254e5
1
Parent(s):
8ea096d
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 |
-
try:
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
except Exception:
|
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
|
|
|
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
|