Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -284,8 +284,16 @@ with gr.Blocks() as demo:
|
|
284 |
print(f"Returning history with {len(history)} items")
|
285 |
return "", history, is_generating, stop_clicked
|
286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
submit_btn.click(
|
288 |
-
|
289 |
inputs=[msg, chatbot, use_web_search, model_dropdown, temperature_slider, num_calls_slider, is_generating, stop_clicked],
|
290 |
outputs=[msg, chatbot, is_generating, stop_clicked],
|
291 |
show_progress=True
|
@@ -293,10 +301,6 @@ with gr.Blocks() as demo:
|
|
293 |
lambda: gr.update(visible=True),
|
294 |
None,
|
295 |
stop_btn
|
296 |
-
).then(
|
297 |
-
lambda: gr.update(visible=False),
|
298 |
-
None,
|
299 |
-
stop_btn
|
300 |
)
|
301 |
|
302 |
stop_btn.click(
|
@@ -310,7 +314,7 @@ with gr.Blocks() as demo:
|
|
310 |
inputs=[chatbot],
|
311 |
outputs=[msg, chatbot]
|
312 |
).then(
|
313 |
-
|
314 |
inputs=[msg, chatbot, use_web_search, model_dropdown, temperature_slider, num_calls_slider, is_generating, stop_clicked],
|
315 |
outputs=[msg, chatbot, is_generating, stop_clicked]
|
316 |
)
|
@@ -341,6 +345,5 @@ with gr.Blocks() as demo:
|
|
341 |
8. Click "Stop" during generation to halt the process.
|
342 |
"""
|
343 |
)
|
344 |
-
|
345 |
if __name__ == "__main__":
|
346 |
demo.launch(share=True)
|
|
|
284 |
print(f"Returning history with {len(history)} items")
|
285 |
return "", history, is_generating, stop_clicked
|
286 |
|
287 |
+
def on_submit(message, history, use_web_search, model, temperature, num_calls, is_generating, stop_clicked):
|
288 |
+
print(f"Submit button clicked with message: {message}")
|
289 |
+
_, new_history, new_is_generating, new_stop_clicked = protected_generate_response(
|
290 |
+
message, history, use_web_search, model, temperature, num_calls, is_generating, lambda: stop_clicked
|
291 |
+
)
|
292 |
+
print(f"New history has {len(new_history)} items")
|
293 |
+
return "", new_history, new_is_generating, new_stop_clicked
|
294 |
+
|
295 |
submit_btn.click(
|
296 |
+
on_submit,
|
297 |
inputs=[msg, chatbot, use_web_search, model_dropdown, temperature_slider, num_calls_slider, is_generating, stop_clicked],
|
298 |
outputs=[msg, chatbot, is_generating, stop_clicked],
|
299 |
show_progress=True
|
|
|
301 |
lambda: gr.update(visible=True),
|
302 |
None,
|
303 |
stop_btn
|
|
|
|
|
|
|
|
|
304 |
)
|
305 |
|
306 |
stop_btn.click(
|
|
|
314 |
inputs=[chatbot],
|
315 |
outputs=[msg, chatbot]
|
316 |
).then(
|
317 |
+
on_submit,
|
318 |
inputs=[msg, chatbot, use_web_search, model_dropdown, temperature_slider, num_calls_slider, is_generating, stop_clicked],
|
319 |
outputs=[msg, chatbot, is_generating, stop_clicked]
|
320 |
)
|
|
|
345 |
8. Click "Stop" during generation to halt the process.
|
346 |
"""
|
347 |
)
|
|
|
348 |
if __name__ == "__main__":
|
349 |
demo.launch(share=True)
|