Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -643,18 +643,41 @@ with gr.Blocks(title="needle3 logits") as demo:
|
|
| 643 |
cmp_btn.click(compare_backends, None, cmp_out, api_name="compare")
|
| 644 |
tun_btn = gr.Button("tuned adapter only (single state)")
|
| 645 |
tun_out = gr.JSON(label="tuned response")
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 658 |
|
| 659 |
with gr.Tab("Method comparison"):
|
| 660 |
gr.Markdown("Which scoring method actually separates the three clear cases?")
|
|
|
|
| 643 |
cmp_btn.click(compare_backends, None, cmp_out, api_name="compare")
|
| 644 |
tun_btn = gr.Button("tuned adapter only (single state)")
|
| 645 |
tun_out = gr.JSON(label="tuned response")
|
| 646 |
+
tun_q = gr.Code(label="questions (JSON) -- passed through verbatim", language="json",
|
| 647 |
+
value=json.dumps({
|
| 648 |
+
"department": {"type": "choice",
|
| 649 |
+
"instructions": "Which team?",
|
| 650 |
+
"criteria": {k: {"description": v, "triggers": TRIG[k]}
|
| 651 |
+
for k, v in
|
| 652 |
+
{"billing": "Payment, charges, refunds.",
|
| 653 |
+
"technical": "Bugs, errors, outages.",
|
| 654 |
+
"account": "Login, password, access."}.items()}},
|
| 655 |
+
"refund_requested": {"type": "noul",
|
| 656 |
+
"instructions": "Is the writer asking for a refund?"}},
|
| 657 |
+
indent=2))
|
| 658 |
+
|
| 659 |
+
def _run_tuned(state, questions_text):
|
| 660 |
+
"""Run the tuned adapter on the CALLER'S questions.
|
| 661 |
+
|
| 662 |
+
This used to take only the state and hardcode its own two questions. That made
|
| 663 |
+
the endpoint useless for comparison work -- a head-to-head that sent its own
|
| 664 |
+
questions was silently answered on a different, fixed set, and the mismatch
|
| 665 |
+
looked like a model result. Questions are now passed through.
|
| 666 |
+
"""
|
| 667 |
+
if isinstance(questions_text, str):
|
| 668 |
+
try:
|
| 669 |
+
qs = json.loads(questions_text)
|
| 670 |
+
except Exception as e:
|
| 671 |
+
return {"error": f"questions is not valid JSON: {e}"}
|
| 672 |
+
else:
|
| 673 |
+
qs = questions_text
|
| 674 |
+
if not isinstance(qs, dict) or not qs:
|
| 675 |
+
return {"error": "questions must be a non-empty JSON object"}
|
| 676 |
+
qs = dict(qs)
|
| 677 |
+
qs["_request_text"] = state
|
| 678 |
+
return answer_tuned(state, qs)
|
| 679 |
+
|
| 680 |
+
tun_btn.click(_run_tuned, [st, tun_q], tun_out, api_name="tuned")
|
| 681 |
|
| 682 |
with gr.Tab("Method comparison"):
|
| 683 |
gr.Markdown("Which scoring method actually separates the three clear cases?")
|