Spaces:
Sleeping
Sleeping
Disable API schema introspection (gradio_client bug w/ Dict[str,Any])
Browse files
app.py
CHANGED
|
@@ -477,28 +477,34 @@ def build_app() -> gr.Blocks:
|
|
| 477 |
history_state = gr.State([])
|
| 478 |
conversation = gr.HTML(_conversation_html([]))
|
| 479 |
|
| 480 |
-
# Wire events
|
|
|
|
| 481 |
upload.upload(
|
| 482 |
fn=on_upload,
|
| 483 |
inputs=upload,
|
| 484 |
outputs=[chip_html, upload_status],
|
|
|
|
| 485 |
)
|
| 486 |
ask_btn.click(
|
| 487 |
fn=on_ask,
|
| 488 |
inputs=[question, history_state],
|
| 489 |
outputs=[conversation, question, history_state],
|
|
|
|
| 490 |
)
|
| 491 |
question.submit(
|
| 492 |
fn=on_ask,
|
| 493 |
inputs=[question, history_state],
|
| 494 |
outputs=[conversation, question, history_state],
|
|
|
|
| 495 |
)
|
| 496 |
reset_btn.click(
|
| 497 |
fn=on_reset,
|
| 498 |
outputs=[chip_html, question, history_state],
|
|
|
|
| 499 |
).then(
|
| 500 |
fn=lambda: _conversation_html([]),
|
| 501 |
outputs=conversation,
|
|
|
|
| 502 |
)
|
| 503 |
|
| 504 |
return demo
|
|
@@ -506,7 +512,7 @@ def build_app() -> gr.Blocks:
|
|
| 506 |
|
| 507 |
if __name__ == "__main__":
|
| 508 |
app = build_app()
|
| 509 |
-
app.launch(
|
| 510 |
server_name="0.0.0.0",
|
| 511 |
server_port=int(os.environ.get("PORT", 7860)),
|
| 512 |
show_api=False,
|
|
|
|
| 477 |
history_state = gr.State([])
|
| 478 |
conversation = gr.HTML(_conversation_html([]))
|
| 479 |
|
| 480 |
+
# Wire events. api_name=False on each event skips JSON-schema api
|
| 481 |
+
# introspection which crashes on Dict[str, Any] returns in gradio<5.
|
| 482 |
upload.upload(
|
| 483 |
fn=on_upload,
|
| 484 |
inputs=upload,
|
| 485 |
outputs=[chip_html, upload_status],
|
| 486 |
+
api_name=False,
|
| 487 |
)
|
| 488 |
ask_btn.click(
|
| 489 |
fn=on_ask,
|
| 490 |
inputs=[question, history_state],
|
| 491 |
outputs=[conversation, question, history_state],
|
| 492 |
+
api_name=False,
|
| 493 |
)
|
| 494 |
question.submit(
|
| 495 |
fn=on_ask,
|
| 496 |
inputs=[question, history_state],
|
| 497 |
outputs=[conversation, question, history_state],
|
| 498 |
+
api_name=False,
|
| 499 |
)
|
| 500 |
reset_btn.click(
|
| 501 |
fn=on_reset,
|
| 502 |
outputs=[chip_html, question, history_state],
|
| 503 |
+
api_name=False,
|
| 504 |
).then(
|
| 505 |
fn=lambda: _conversation_html([]),
|
| 506 |
outputs=conversation,
|
| 507 |
+
api_name=False,
|
| 508 |
)
|
| 509 |
|
| 510 |
return demo
|
|
|
|
| 512 |
|
| 513 |
if __name__ == "__main__":
|
| 514 |
app = build_app()
|
| 515 |
+
app.queue(api_open=False).launch(
|
| 516 |
server_name="0.0.0.0",
|
| 517 |
server_port=int(os.environ.get("PORT", 7860)),
|
| 518 |
show_api=False,
|