Spaces:
Running
Running
bitliu
commited on
Commit
·
ac47b0e
1
Parent(s):
5f5c5b7
update
Browse filesSigned-off-by: bitliu <[email protected]>
app.py
CHANGED
|
@@ -519,6 +519,35 @@ def main():
|
|
| 519 |
components.html(
|
| 520 |
create_highlighted_html_simple(result["text"], entities), height=150
|
| 521 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 522 |
|
| 523 |
# Raw Prediction Data expander
|
| 524 |
with st.expander("🔬 Raw Prediction Data"):
|
|
|
|
| 519 |
components.html(
|
| 520 |
create_highlighted_html_simple(result["text"], entities), height=150
|
| 521 |
)
|
| 522 |
+
elif result["type"] == "toolcall_verifier":
|
| 523 |
+
unauthorized = result["unauthorized"]
|
| 524 |
+
|
| 525 |
+
if unauthorized:
|
| 526 |
+
st.error(f"⚠️ BLOCKED: Unauthorized tool call detected!")
|
| 527 |
+
st.markdown(f"**Flagged tokens:** {[t for t, _ in unauthorized[:10]]}")
|
| 528 |
+
st.markdown(f"**Total unauthorized tokens:** {len(unauthorized)}")
|
| 529 |
+
else:
|
| 530 |
+
st.success("✅ Tool call authorized")
|
| 531 |
+
|
| 532 |
+
st.markdown("### Input Format")
|
| 533 |
+
st.code(result["input_text"], language="text")
|
| 534 |
+
|
| 535 |
+
st.markdown("### Token-Level Classification")
|
| 536 |
+
# Create a simple table view
|
| 537 |
+
token_label_pairs = list(zip(result["tokens"], result["labels"]))
|
| 538 |
+
# Show first 50 tokens to avoid overwhelming the UI
|
| 539 |
+
display_tokens = token_label_pairs[:50]
|
| 540 |
+
|
| 541 |
+
for i in range(0, len(display_tokens), 5):
|
| 542 |
+
cols = st.columns(5)
|
| 543 |
+
for j, col in enumerate(cols):
|
| 544 |
+
if i + j < len(display_tokens):
|
| 545 |
+
token, label = display_tokens[i + j]
|
| 546 |
+
color = "🔴" if label == "UNAUTHORIZED" else "🟢"
|
| 547 |
+
col.markdown(f"{color} `{token}`")
|
| 548 |
+
|
| 549 |
+
if len(token_label_pairs) > 50:
|
| 550 |
+
st.info(f"Showing first 50 of {len(token_label_pairs)} tokens")
|
| 551 |
|
| 552 |
# Raw Prediction Data expander
|
| 553 |
with st.expander("🔬 Raw Prediction Data"):
|