Spaces:
Sleeping
Sleeping
Update app/main.py
Browse files- app/main.py +17 -7
app/main.py
CHANGED
|
@@ -501,12 +501,17 @@ def build_ui():
|
|
| 501 |
with gr.Blocks(title="Query LLM") as demo:
|
| 502 |
gr.Markdown("# Query LLM")
|
| 503 |
|
|
|
|
| 504 |
with gr.Row():
|
| 505 |
-
mode = gr.Radio(["short", "detailed"], value="short", label="Answer length")
|
| 506 |
-
model_id = gr.Dropdown(MODEL_IDS, value=ModelName.mistral_v02.value, label="Choose the LLM")
|
| 507 |
-
request_timeout_ms = gr.Slider(1000, 900000, value=REQUEST_TIMEOUT_MS, step=500, label="Timeout (ms)")
|
| 508 |
-
|
| 509 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 510 |
|
| 511 |
help_output = gr.Markdown(value="(Click HELP to load model comparison…)", visible=True)
|
| 512 |
|
|
@@ -524,7 +529,8 @@ def build_ui():
|
|
| 524 |
try:
|
| 525 |
if os.path.getsize(path) > FILE_MAX_MB * 1024 * 1024:
|
| 526 |
return f"[Error reading file: file too large > {FILE_MAX_MB} MB]"
|
| 527 |
-
except Exception:
|
|
|
|
| 528 |
return _load_file_to_text(path)
|
| 529 |
|
| 530 |
file_upl.change(fn=_on_file_change, inputs=file_upl, outputs=paper)
|
|
@@ -538,7 +544,8 @@ def build_ui():
|
|
| 538 |
recalc_btn = gr.Button("Update token info", variant="secondary")
|
| 539 |
recalc_btn.click(fn=_token_info_for_paper, inputs=[paper, question, model_id, mode], outputs=[token_info])
|
| 540 |
|
| 541 |
-
out = gr.Textbox(label="Answer", lines=10, interactive=False, show_copy_button=True,
|
|
|
|
| 542 |
|
| 543 |
gr.Button("Ask").click(
|
| 544 |
fn=ui_submit,
|
|
@@ -546,11 +553,14 @@ def build_ui():
|
|
| 546 |
outputs=[out, run_report],
|
| 547 |
)
|
| 548 |
|
|
|
|
| 549 |
help_btn.click(fn=build_help_markdown, inputs=None, outputs=[help_output])
|
|
|
|
| 550 |
latency_all_btn.click(fn=build_help_with_all_latencies, inputs=None, outputs=[help_output])
|
| 551 |
|
| 552 |
return demo
|
| 553 |
|
|
|
|
| 554 |
# small helper used by UI
|
| 555 |
def _load_file_to_text(path: Optional[str]) -> str:
|
| 556 |
if not path: return ""
|
|
|
|
| 501 |
with gr.Blocks(title="Query LLM") as demo:
|
| 502 |
gr.Markdown("# Query LLM")
|
| 503 |
|
| 504 |
+
# שורת הבקרות
|
| 505 |
with gr.Row():
|
| 506 |
+
mode = gr.Radio(["short", "detailed"], value="short", label="Answer length", scale=1)
|
| 507 |
+
model_id = gr.Dropdown(MODEL_IDS, value=ModelName.mistral_v02.value, label="Choose the LLM", scale=1)
|
| 508 |
+
request_timeout_ms = gr.Slider(1000, 900000, value=REQUEST_TIMEOUT_MS, step=500, label="Timeout (ms)", scale=2)
|
| 509 |
+
|
| 510 |
+
# שורת כפתורי עזרה/Latency
|
| 511 |
+
with gr.Row():
|
| 512 |
+
help_btn = gr.Button("HELP", variant="secondary", scale=0)
|
| 513 |
+
latency_sel_btn = gr.Button("Refresh latency (selected)", variant="secondary", scale=0)
|
| 514 |
+
latency_all_btn = gr.Button("Refresh latency (all)", variant="secondary", scale=0)
|
| 515 |
|
| 516 |
help_output = gr.Markdown(value="(Click HELP to load model comparison…)", visible=True)
|
| 517 |
|
|
|
|
| 529 |
try:
|
| 530 |
if os.path.getsize(path) > FILE_MAX_MB * 1024 * 1024:
|
| 531 |
return f"[Error reading file: file too large > {FILE_MAX_MB} MB]"
|
| 532 |
+
except Exception:
|
| 533 |
+
pass
|
| 534 |
return _load_file_to_text(path)
|
| 535 |
|
| 536 |
file_upl.change(fn=_on_file_change, inputs=file_upl, outputs=paper)
|
|
|
|
| 544 |
recalc_btn = gr.Button("Update token info", variant="secondary")
|
| 545 |
recalc_btn.click(fn=_token_info_for_paper, inputs=[paper, question, model_id, mode], outputs=[token_info])
|
| 546 |
|
| 547 |
+
out = gr.Textbox(label="Answer", lines=10, interactive=False, show_copy_button=True,
|
| 548 |
+
placeholder="Answer will appear here...")
|
| 549 |
|
| 550 |
gr.Button("Ask").click(
|
| 551 |
fn=ui_submit,
|
|
|
|
| 553 |
outputs=[out, run_report],
|
| 554 |
)
|
| 555 |
|
| 556 |
+
# חיבורים של הכפתורים
|
| 557 |
help_btn.click(fn=build_help_markdown, inputs=None, outputs=[help_output])
|
| 558 |
+
latency_sel_btn.click(fn=build_help_with_latency, inputs=[model_id], outputs=[help_output])
|
| 559 |
latency_all_btn.click(fn=build_help_with_all_latencies, inputs=None, outputs=[help_output])
|
| 560 |
|
| 561 |
return demo
|
| 562 |
|
| 563 |
+
|
| 564 |
# small helper used by UI
|
| 565 |
def _load_file_to_text(path: Optional[str]) -> str:
|
| 566 |
if not path: return ""
|