AlephBeth-AI commited on
Commit
1569836
·
verified ·
1 Parent(s): d4a174e

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -476,7 +476,7 @@ PLOTLY_CLICK_JS = """
476
  # Gradio Interface
477
  # ---------------------------------------------------------------------------
478
  TITLE_HTML = """
479
- <div style="text-align:center; padding:10px 0;">
480
  <h1 style="font-size:1.8em; margin:0;">GuardLLM - Prompt Security Visualizer</h1>
481
  <p style="color:#94a3b8; font-size:0.95em; margin-top:4px;">
482
  Interactive t-SNE embedding space &bull;
@@ -488,11 +488,32 @@ TITLE_HTML = """
488
  </div>
489
  """
490
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
  with gr.Blocks(
492
  title="GuardLLM - Prompt Security Visualizer",
493
  ) as demo:
494
 
495
  gr.HTML(TITLE_HTML)
 
496
 
497
  click_index = gr.Textbox(
498
  value="",
 
476
  # Gradio Interface
477
  # ---------------------------------------------------------------------------
478
  TITLE_HTML = """
479
+ <div style="text-align:center; padding:10px 0 4px 0;">
480
  <h1 style="font-size:1.8em; margin:0;">GuardLLM - Prompt Security Visualizer</h1>
481
  <p style="color:#94a3b8; font-size:0.95em; margin-top:4px;">
482
  Interactive t-SNE embedding space &bull;
 
488
  </div>
489
  """
490
 
491
+ HOW_TO_HTML = """
492
+ <div style="background:linear-gradient(135deg, #0f172a 0%, #1e293b 100%); border:1px solid #334155; border-radius:12px; padding:16px 20px; margin:0 0 8px 0; font-family:system-ui,sans-serif;">
493
+ <div style="color:#e2e8f0; font-weight:700; font-size:1em; margin-bottom:8px;">How to use this tool</div>
494
+ <div style="display:flex; flex-wrap:wrap; gap:12px;">
495
+ <div style="flex:1; min-width:180px; background:#1e293b; border-radius:8px; padding:10px 12px;">
496
+ <div style="color:#60a5fa; font-weight:600; font-size:0.85em; margin-bottom:4px;">1. Explore the map</div>
497
+ <div style="color:#94a3b8; font-size:0.8em; line-height:1.4;">Each dot represents a prompt from the dataset, positioned by semantic similarity. Colors indicate attack categories. Hover to preview, scroll to zoom, drag to pan.</div>
498
+ </div>
499
+ <div style="flex:1; min-width:180px; background:#1e293b; border-radius:8px; padding:10px 12px;">
500
+ <div style="color:#f59e0b; font-weight:600; font-size:0.85em; margin-bottom:4px;">2. Click to analyze</div>
501
+ <div style="color:#94a3b8; font-size:0.8em; line-height:1.4;">Click any point to run it through <strong style="color:#cbd5e1;">Llama Prompt Guard 2</strong>. The right panel will show the risk classification, safety score, and confidence breakdown.</div>
502
+ </div>
503
+ <div style="flex:1; min-width:180px; background:#1e293b; border-radius:8px; padding:10px 12px;">
504
+ <div style="color:#22c55e; font-weight:600; font-size:0.85em; margin-bottom:4px;">3. Test your own prompts</div>
505
+ <div style="color:#94a3b8; font-size:0.8em; line-height:1.4;">Type or paste any prompt in the <strong style="color:#cbd5e1;">Custom prompt</strong> field and hit Analyze to check if it would be flagged as an injection attempt.</div>
506
+ </div>
507
+ </div>
508
+ </div>
509
+ """
510
+
511
  with gr.Blocks(
512
  title="GuardLLM - Prompt Security Visualizer",
513
  ) as demo:
514
 
515
  gr.HTML(TITLE_HTML)
516
+ gr.HTML(HOW_TO_HTML)
517
 
518
  click_index = gr.Textbox(
519
  value="",