Luiserb commited on
Commit
9e395fa
Β·
1 Parent(s): c63a2d7

update dashboard

Browse files
Files changed (1) hide show
  1. app.py +30 -28
app.py CHANGED
@@ -315,8 +315,7 @@ def execute_pipeline(
315
  # STEP 2 & 3: COMPRESS & SHIELD (With Manual Rule Injection)
316
  shield_res = pipeline.service._shield_with_cache(
317
  raw_prompt,
318
- privacy_mode=privacy_mode,
319
- mode_override=mode
320
  )
321
 
322
  # INJECT MANUAL
@@ -505,11 +504,13 @@ with gr.Blocks(title="NLProxy Demo", theme=gr.themes.Soft()) as demo:
505
  placeholder="FORBID: AWS, Python; MANDATE: GCP, Rust",
506
  value="",
507
  lines=2,
 
508
  info="Define explicit restrictions that regex might miss"
509
  )
510
  auto_correct_checkbox = gr.Checkbox(
511
  label="Auto-Correct Low Confidence",
512
  value=False,
 
513
  info="Regenerate response if confidence < threshold"
514
  )
515
  min_confidence_slider = gr.Slider(
@@ -517,39 +518,41 @@ with gr.Blocks(title="NLProxy Demo", theme=gr.themes.Soft()) as demo:
517
  maximum=1.0,
518
  value=0.6,
519
  step=0.05,
520
- label="Min Confidence Threshold"
 
521
  )
522
-
 
523
  with gr.Column(scale=1):
524
  gr.Markdown("#### πŸ“₯ Step 0: Input & Configuration")
525
  raw_prompt = gr.Textbox(
526
  label="Dirty User Prompt (PII + Business Rules)",
527
  value="""Hi, I'm Sarah Chen (sarah.chen@acmecorp.com, +1-555-0198). We need to migrate our legacy payment processing system currently running on server 10.20.30.40. The system handles ~50k transactions/day with a budget of $150,000 USD for Q3.
528
 
529
- CRITICAL REQUIREMENTS:
530
- - Do NOT use AWS services or Python, we are exclusively on GCP with Rust for compliance and memory safety.
531
- - The new microservice MUST be written in Rust.
532
- - Never expose internal IPs or database credentials in responses.
533
- - Primary API: https://internal.acmecorp.com/api/v2/payments
534
 
535
- Please design the architecture for the new event-driven payment processor.""",
536
  lines=12
537
  )
538
  llm_response = gr.Textbox(
539
  label="Simulated LLM Response (Coherent but Hallucinated)",
540
  value="""Here's the architecture design for your event-driven payment processor:
541
 
542
- 1. **Compute Layer**: I recommend using AWS Lambda with Python for serverless scalability. Python's boto3 library integrates perfectly with AWS services.
543
 
544
- 2. **Message Queue**: Use Amazon SQS to handle the 50k daily transactions with dead-letter queues for failed payments.
545
 
546
- 3. **Database**: Store transaction records in DynamoDB. You can connect to your legacy server at 10.20.30.40 and also add a read replica at 192.168.1.100 for better performance.
547
 
548
- 4. **Monitoring**: Set up CloudWatch alerts for transaction failures and latency spikes above 200ms.
549
 
550
- 5. **Cost Analysis**: The total estimated cost is $45,000/month using AWS, well within your $150,000 Q3 budget.
551
 
552
- This Python-based serverless architecture will give you excellent developer experience and automatic scaling.""",
553
  lines=14
554
  )
555
 
@@ -567,7 +570,6 @@ This Python-based serverless architecture will give you excellent developer expe
567
  step=0.05,
568
  label="Compression Aggressiveness"
569
  )
570
-
571
  with gr.Row():
572
  privacy_checkbox = gr.Checkbox(
573
  label="Privacy Mode (Strict PII Anonymization)",
@@ -578,26 +580,26 @@ This Python-based serverless architecture will give you excellent developer expe
578
  label="Use NLI Verification",
579
  value=True
580
  )
581
-
582
- run_btn = gr.Button("πŸš€ Run Full Pipeline", variant="primary")
583
-
584
  with gr.Column(scale=1):
585
  gr.Markdown("#### πŸ›‘οΈ Step 1: Firewall (Pre-flight)")
586
  firewall_out = gr.Markdown()
587
 
588
  gr.Markdown("#### πŸ—œοΈ Step 2 & 3: Compress & Shield (TruthTable)")
589
- compress_out = gr.Textbox(label="Compressed Prompt (Sent to LLM)", interactive=False, lines=8)
590
  truthtable_out = gr.Markdown()
591
- metrics_out = gr.Markdown()
592
-
593
- with gr.Row():
594
- with gr.Column(scale=1):
595
  gr.Markdown("#### 🧹 Step 4: Response Corrector")
596
- corrector_out = gr.Textbox(label="Sanitized LLM Output (Post-Flight)", interactive=False, lines=8)
597
- with gr.Column(scale=1):
598
  gr.Markdown("#### πŸ” Step 5: Post-LLM Verifier (NLI)")
599
  verifier_out = gr.Markdown()
600
-
 
 
 
 
 
601
  run_btn.click(
602
  fn=execute_pipeline,
603
  inputs=[
 
315
  # STEP 2 & 3: COMPRESS & SHIELD (With Manual Rule Injection)
316
  shield_res = pipeline.service._shield_with_cache(
317
  raw_prompt,
318
+ mode=mode
 
319
  )
320
 
321
  # INJECT MANUAL
 
504
  placeholder="FORBID: AWS, Python; MANDATE: GCP, Rust",
505
  value="",
506
  lines=2,
507
+ scale=2,
508
  info="Define explicit restrictions that regex might miss"
509
  )
510
  auto_correct_checkbox = gr.Checkbox(
511
  label="Auto-Correct Low Confidence",
512
  value=False,
513
+ scale=1,
514
  info="Regenerate response if confidence < threshold"
515
  )
516
  min_confidence_slider = gr.Slider(
 
518
  maximum=1.0,
519
  value=0.6,
520
  step=0.05,
521
+ label="Min Confidence Threshold",
522
+ scale=1
523
  )
524
+
525
+ with gr.Row():
526
  with gr.Column(scale=1):
527
  gr.Markdown("#### πŸ“₯ Step 0: Input & Configuration")
528
  raw_prompt = gr.Textbox(
529
  label="Dirty User Prompt (PII + Business Rules)",
530
  value="""Hi, I'm Sarah Chen (sarah.chen@acmecorp.com, +1-555-0198). We need to migrate our legacy payment processing system currently running on server 10.20.30.40. The system handles ~50k transactions/day with a budget of $150,000 USD for Q3.
531
 
532
+ CRITICAL REQUIREMENTS:
533
+ - Do NOT use AWS services or Python, we are exclusively on GCP with Rust for compliance and memory safety.
534
+ - The new microservice MUST be written in Rust.
535
+ - Never expose internal IPs or database credentials in responses.
536
+ - Primary API: https://internal.acmecorp.com/api/v2/payments
537
 
538
+ Please design the architecture for the new event-driven payment processor.""",
539
  lines=12
540
  )
541
  llm_response = gr.Textbox(
542
  label="Simulated LLM Response (Coherent but Hallucinated)",
543
  value="""Here's the architecture design for your event-driven payment processor:
544
 
545
+ 1. **Compute Layer**: I recommend using AWS Lambda with Python for serverless scalability. Python's boto3 library integrates perfectly with AWS services.
546
 
547
+ 2. **Message Queue**: Use Amazon SQS to handle the 50k daily transactions with dead-letter queues for failed payments.
548
 
549
+ 3. **Database**: Store transaction records in DynamoDB. You can connect to your legacy server at 10.20.30.40 and also add a read replica at 192.168.1.100 for better performance.
550
 
551
+ 4. **Monitoring**: Set up CloudWatch alerts for transaction failures and latency spikes above 200ms.
552
 
553
+ 5. **Cost Analysis**: The total estimated cost is $45,000/month using AWS, well within your $150,000 Q3 budget.
554
 
555
+ This Python-based serverless architecture will give you excellent developer experience and automatic scaling.""",
556
  lines=14
557
  )
558
 
 
570
  step=0.05,
571
  label="Compression Aggressiveness"
572
  )
 
573
  with gr.Row():
574
  privacy_checkbox = gr.Checkbox(
575
  label="Privacy Mode (Strict PII Anonymization)",
 
580
  label="Use NLI Verification",
581
  value=True
582
  )
583
+
 
 
584
  with gr.Column(scale=1):
585
  gr.Markdown("#### πŸ›‘οΈ Step 1: Firewall (Pre-flight)")
586
  firewall_out = gr.Markdown()
587
 
588
  gr.Markdown("#### πŸ—œοΈ Step 2 & 3: Compress & Shield (TruthTable)")
589
+ compress_out = gr.Textbox(label="Compressed Prompt (Sent to LLM)", interactive=False, lines=6)
590
  truthtable_out = gr.Markdown()
591
+
 
 
 
592
  gr.Markdown("#### 🧹 Step 4: Response Corrector")
593
+ corrector_out = gr.Textbox(label="Sanitized LLM Output (Post-Flight)", interactive=False, lines=6)
594
+
595
  gr.Markdown("#### πŸ” Step 5: Post-LLM Verifier (NLI)")
596
  verifier_out = gr.Markdown()
597
+
598
+ gr.Markdown("#### πŸ“Š Metrics")
599
+ metrics_out = gr.Markdown()
600
+
601
+ run_btn = gr.Button("πŸš€ Run Full Pipeline", variant="primary")
602
+
603
  run_btn.click(
604
  fn=execute_pipeline,
605
  inputs=[