Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,10 +63,10 @@ def score_colour(s):
|
|
| 63 |
def highlight(summary, spans):
|
| 64 |
out = esc(summary)
|
| 65 |
for sp in sorted({s for s in spans if s and len(str(s)) > 4}, key=len, reverse=True):
|
| 66 |
-
out = out.replace(esc(sp), f"<mark style='background:#ffe0b3;color:
|
| 67 |
return out.replace("\n", "<br>")
|
| 68 |
|
| 69 |
-
TEXT = "#
|
| 70 |
MUTED = "#1a1a1a"
|
| 71 |
|
| 72 |
def render_scores(results, valid, degen):
|
|
@@ -74,25 +74,25 @@ def render_scores(results, valid, degen):
|
|
| 74 |
parts = []
|
| 75 |
if not valid:
|
| 76 |
parts.append(f"<div style='padding:10px;border-left:4px solid #b5523f;background:#fbeae6;"
|
| 77 |
-
f"color:
|
| 78 |
f"<b>Validity screen: DEGENERATE</b> — flagged as <code>{esc(degen)}</code>. "
|
| 79 |
f"Fault-absence dimensions (overclaiming, uncertainty) are not scored for "
|
| 80 |
f"non-functional output; faithfulness is reported as minimal.</div>")
|
| 81 |
else:
|
| 82 |
parts.append(f"<div style='padding:8px;border-left:4px solid #2e8f6a;background:#eaf6f0;"
|
| 83 |
-
f"color:
|
| 84 |
|
| 85 |
all_spans = []
|
| 86 |
for label, res in results.items():
|
| 87 |
key, sfield, ifield, ikeys = DIMENSIONS[label]
|
| 88 |
if "error" in res:
|
| 89 |
-
parts.append(f"<div style='margin-top:12px;color:
|
| 90 |
f"<span style='color:#b5523f'>could not score ({esc(res['error'])})</span></div>")
|
| 91 |
continue
|
| 92 |
score = res.get(sfield, "–")
|
| 93 |
col = score_colour(score)
|
| 94 |
head = (f"<div style='margin-top:14px;padding:8px;border:1px solid #e3e7ee;border-radius:8px;"
|
| 95 |
-
f"background:#ffffff;color:
|
| 96 |
f"<span style='font-size:15px;font-weight:700'>{esc(label)}</span> "
|
| 97 |
f"<span style='float:right;font-weight:700;color:{col}'>{esc(score)} / 5</span>")
|
| 98 |
body = ""
|
|
@@ -100,12 +100,12 @@ def render_scores(results, valid, degen):
|
|
| 100 |
flags = [("Methods", res.get("methods_present")),
|
| 101 |
("Limitations", res.get("limitations_present")),
|
| 102 |
("Population", res.get("population_present"))]
|
| 103 |
-
body += f"<div style='margin-top:6px;font-size:13px;color:
|
| 104 |
f"{n}: {'✓' if v else '✗'}" for n, v in flags) + "</div>"
|
| 105 |
elif ifield:
|
| 106 |
issues = res.get(ifield) or []
|
| 107 |
if issues:
|
| 108 |
-
body += f"<ul style='margin:6px 0 0 0;font-size:13px;color:
|
| 109 |
for it in issues:
|
| 110 |
if not isinstance(it, dict): continue
|
| 111 |
span = it.get(ikeys[0], "")
|
|
@@ -127,9 +127,9 @@ def render_scores(results, valid, degen):
|
|
| 127 |
|
| 128 |
def render_summary(summary, all_spans):
|
| 129 |
hi = highlight(summary, all_spans)
|
| 130 |
-
return (f"<div style='font-family:system-ui;color:
|
| 131 |
f"<div style='padding:10px;background:#fbfaf7;border:1px solid #ece7dc;border-radius:8px;"
|
| 132 |
-
f"font-size:14px;line-height:1.6;color:
|
| 133 |
|
| 134 |
# ------------------------------------------------------------------ main callback
|
| 135 |
def _err(msg, remaining):
|
|
|
|
| 63 |
def highlight(summary, spans):
|
| 64 |
out = esc(summary)
|
| 65 |
for sp in sorted({s for s in spans if s and len(str(s)) > 4}, key=len, reverse=True):
|
| 66 |
+
out = out.replace(esc(sp), f"<mark style='background:#ffe0b3;color:#000000'>{esc(sp)}</mark>")
|
| 67 |
return out.replace("\n", "<br>")
|
| 68 |
|
| 69 |
+
TEXT = "#000000"
|
| 70 |
MUTED = "#1a1a1a"
|
| 71 |
|
| 72 |
def render_scores(results, valid, degen):
|
|
|
|
| 74 |
parts = []
|
| 75 |
if not valid:
|
| 76 |
parts.append(f"<div style='padding:10px;border-left:4px solid #b5523f;background:#fbeae6;"
|
| 77 |
+
f"color:#000000'>"
|
| 78 |
f"<b>Validity screen: DEGENERATE</b> — flagged as <code>{esc(degen)}</code>. "
|
| 79 |
f"Fault-absence dimensions (overclaiming, uncertainty) are not scored for "
|
| 80 |
f"non-functional output; faithfulness is reported as minimal.</div>")
|
| 81 |
else:
|
| 82 |
parts.append(f"<div style='padding:8px;border-left:4px solid #2e8f6a;background:#eaf6f0;"
|
| 83 |
+
f"color:#000000'><b>Validity screen: functional output</b></div>")
|
| 84 |
|
| 85 |
all_spans = []
|
| 86 |
for label, res in results.items():
|
| 87 |
key, sfield, ifield, ikeys = DIMENSIONS[label]
|
| 88 |
if "error" in res:
|
| 89 |
+
parts.append(f"<div style='margin-top:12px;color:#000000'><b>{esc(label)}</b>: "
|
| 90 |
f"<span style='color:#b5523f'>could not score ({esc(res['error'])})</span></div>")
|
| 91 |
continue
|
| 92 |
score = res.get(sfield, "–")
|
| 93 |
col = score_colour(score)
|
| 94 |
head = (f"<div style='margin-top:14px;padding:8px;border:1px solid #e3e7ee;border-radius:8px;"
|
| 95 |
+
f"background:#ffffff;color:#000000'>"
|
| 96 |
f"<span style='font-size:15px;font-weight:700'>{esc(label)}</span> "
|
| 97 |
f"<span style='float:right;font-weight:700;color:{col}'>{esc(score)} / 5</span>")
|
| 98 |
body = ""
|
|
|
|
| 100 |
flags = [("Methods", res.get("methods_present")),
|
| 101 |
("Limitations", res.get("limitations_present")),
|
| 102 |
("Population", res.get("population_present"))]
|
| 103 |
+
body += f"<div style='margin-top:6px;font-size:13px;color:#000000'>" + " · ".join(
|
| 104 |
f"{n}: {'✓' if v else '✗'}" for n, v in flags) + "</div>"
|
| 105 |
elif ifield:
|
| 106 |
issues = res.get(ifield) or []
|
| 107 |
if issues:
|
| 108 |
+
body += f"<ul style='margin:6px 0 0 0;font-size:13px;color:#000000'>"
|
| 109 |
for it in issues:
|
| 110 |
if not isinstance(it, dict): continue
|
| 111 |
span = it.get(ikeys[0], "")
|
|
|
|
| 127 |
|
| 128 |
def render_summary(summary, all_spans):
|
| 129 |
hi = highlight(summary, all_spans)
|
| 130 |
+
return (f"<div style='font-family:system-ui;color:#000000'>"
|
| 131 |
f"<div style='padding:10px;background:#fbfaf7;border:1px solid #ece7dc;border-radius:8px;"
|
| 132 |
+
f"font-size:14px;line-height:1.6;color:#000000'>{hi}</div></div>")
|
| 133 |
|
| 134 |
# ------------------------------------------------------------------ main callback
|
| 135 |
def _err(msg, remaining):
|