Spaces:
Sleeping
Sleeping
Clear button now resets the upload file too
Browse files
app.py
CHANGED
|
@@ -730,8 +730,14 @@ def on_load_demo() -> Tuple[str, str, list]:
|
|
| 730 |
|
| 731 |
|
| 732 |
@spaces.GPU(duration=60)
|
| 733 |
-
def _gpu_process(question: str) -> dict:
|
| 734 |
-
"""Inference only — models already on cuda from module-level loading.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 735 |
agent = get_agent()
|
| 736 |
return agent.process(question)
|
| 737 |
|
|
@@ -768,9 +774,11 @@ def on_ask(question: str, history: list) -> Generator[Tuple[str, str, list], Non
|
|
| 768 |
yield _conversation_html(history), "", history
|
| 769 |
|
| 770 |
|
| 771 |
-
def on_reset()
|
|
|
|
| 772 |
get_agent().reset()
|
| 773 |
-
|
|
|
|
| 774 |
|
| 775 |
|
| 776 |
# ====================================================================== APP
|
|
@@ -859,7 +867,7 @@ def build_app() -> gr.Blocks:
|
|
| 859 |
)
|
| 860 |
reset_btn.click(
|
| 861 |
fn=on_reset,
|
| 862 |
-
outputs=[chip_html, question, conversation, history_state],
|
| 863 |
api_name=False,
|
| 864 |
)
|
| 865 |
|
|
|
|
| 730 |
|
| 731 |
|
| 732 |
@spaces.GPU(duration=60)
|
| 733 |
+
def _gpu_process(question: str, oauth_token=None) -> dict:
|
| 734 |
+
"""Inference only — models already on cuda from module-level loading.
|
| 735 |
+
|
| 736 |
+
The oauth_token parameter is auto-injected by Gradio when the user is
|
| 737 |
+
logged in via gr.LoginButton; spaces.GPU uses it to attribute the GPU
|
| 738 |
+
call to the authenticated user (so they get their Pro quota instead of
|
| 739 |
+
being treated as anonymous).
|
| 740 |
+
"""
|
| 741 |
agent = get_agent()
|
| 742 |
return agent.process(question)
|
| 743 |
|
|
|
|
| 774 |
yield _conversation_html(history), "", history
|
| 775 |
|
| 776 |
|
| 777 |
+
def on_reset():
|
| 778 |
+
"""Clear everything: uploaded file, chip, question, conversation, agent state."""
|
| 779 |
get_agent().reset()
|
| 780 |
+
# Order: upload, chip_html, question, conversation, history_state
|
| 781 |
+
return None, "", "", _conversation_html([]), []
|
| 782 |
|
| 783 |
|
| 784 |
# ====================================================================== APP
|
|
|
|
| 867 |
)
|
| 868 |
reset_btn.click(
|
| 869 |
fn=on_reset,
|
| 870 |
+
outputs=[upload, chip_html, question, conversation, history_state],
|
| 871 |
api_name=False,
|
| 872 |
)
|
| 873 |
|