Spaces:
Sleeping
Sleeping
Fix serving stability: restore clean direct event wiring on decide_btn and gr.Examples
Browse files
app.py
CHANGED
|
@@ -5,10 +5,7 @@ Permutation-Equivariant Decision Model
|
|
| 5 |
|
| 6 |
from __future__ import annotations
|
| 7 |
|
| 8 |
-
import time
|
| 9 |
-
from typing import Sequence
|
| 10 |
import gradio as gr
|
| 11 |
-
import torch
|
| 12 |
from invariantone import InvariantOne
|
| 13 |
|
| 14 |
# ---------------------------------------------------------
|
|
@@ -95,10 +92,6 @@ def remove_option_field(count: int):
|
|
| 95 |
return [new_count] + updates
|
| 96 |
|
| 97 |
|
| 98 |
-
def reset_extra_options():
|
| 99 |
-
return 4, gr.update(visible=False, value=""), gr.update(visible=False, value="")
|
| 100 |
-
|
| 101 |
-
|
| 102 |
# ---------------------------------------------------------
|
| 103 |
# Gradio Interface Definition
|
| 104 |
# ---------------------------------------------------------
|
|
@@ -243,24 +236,14 @@ with gr.Blocks(title="InvariantOne — Permutation-Equivariant Decision Model")
|
|
| 243 |
|
| 244 |
breakdown_table = gr.Markdown()
|
| 245 |
|
| 246 |
-
# Clean execution without component-covering progress overlays
|
| 247 |
decide_btn.click(
|
| 248 |
-
fn=lambda: gr.update(interactive=False, value="Deciding... (HF Free CPU)"),
|
| 249 |
-
outputs=[decide_btn],
|
| 250 |
-
show_progress="hidden",
|
| 251 |
-
).then(
|
| 252 |
fn=decide_action,
|
| 253 |
inputs=[state_box, question_box] + option_boxes,
|
| 254 |
outputs=[selected_box, top_prob_box, margin_box, prob_label, breakdown_table],
|
| 255 |
-
show_progress="minimal",
|
| 256 |
-
).then(
|
| 257 |
-
fn=lambda: gr.update(interactive=True, value="Decide Action"),
|
| 258 |
-
outputs=[decide_btn],
|
| 259 |
-
show_progress="hidden",
|
| 260 |
)
|
| 261 |
|
| 262 |
# Pre-populate structured intended-use examples
|
| 263 |
-
|
| 264 |
examples=[
|
| 265 |
[
|
| 266 |
"Boiler steam pressure is 96 bar. The operating rule states: If steam pressure exceeds 90 bar, open the emergency relief valve; otherwise, maintain normal burner firing.",
|
|
@@ -314,10 +297,5 @@ with gr.Blocks(title="InvariantOne — Permutation-Equivariant Decision Model")
|
|
| 314 |
inputs=[state_box, question_box] + option_boxes[:4],
|
| 315 |
)
|
| 316 |
|
| 317 |
-
examples_handler.dataset.click(
|
| 318 |
-
fn=reset_extra_options,
|
| 319 |
-
outputs=[option_count_state, option_boxes[4], option_boxes[5]],
|
| 320 |
-
)
|
| 321 |
-
|
| 322 |
if __name__ == "__main__":
|
| 323 |
demo.launch()
|
|
|
|
| 5 |
|
| 6 |
from __future__ import annotations
|
| 7 |
|
|
|
|
|
|
|
| 8 |
import gradio as gr
|
|
|
|
| 9 |
from invariantone import InvariantOne
|
| 10 |
|
| 11 |
# ---------------------------------------------------------
|
|
|
|
| 92 |
return [new_count] + updates
|
| 93 |
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
# ---------------------------------------------------------
|
| 96 |
# Gradio Interface Definition
|
| 97 |
# ---------------------------------------------------------
|
|
|
|
| 236 |
|
| 237 |
breakdown_table = gr.Markdown()
|
| 238 |
|
|
|
|
| 239 |
decide_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
fn=decide_action,
|
| 241 |
inputs=[state_box, question_box] + option_boxes,
|
| 242 |
outputs=[selected_box, top_prob_box, margin_box, prob_label, breakdown_table],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
)
|
| 244 |
|
| 245 |
# Pre-populate structured intended-use examples
|
| 246 |
+
gr.Examples(
|
| 247 |
examples=[
|
| 248 |
[
|
| 249 |
"Boiler steam pressure is 96 bar. The operating rule states: If steam pressure exceeds 90 bar, open the emergency relief valve; otherwise, maintain normal burner firing.",
|
|
|
|
| 297 |
inputs=[state_box, question_box] + option_boxes[:4],
|
| 298 |
)
|
| 299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
if __name__ == "__main__":
|
| 301 |
demo.launch()
|