Skip to content

DeepTeam is a framework to red team LLMs and AI agents.

print table

penguinef3afbc7ee741
diff --git a/a.py b/a.py
index e0527578..47c624ac 100644
--- a/a.py
+++ b/a.py
@@ -115,9 +115,23 @@ api_security = CustomVulnerability(
red_team(
model_callback=model_callback,
- vulnerabilities=[api_security],
+ vulnerabilities=[
+ bias,
+ toxicity,
+ unauthorized_access,
+ # misinformation,
+ # pii_leakage,
+ # prompt_leakage,
+ # intellectual_property,
+ # excessive_agency,
+ # robustness,
+ # competition,
+ # illegal_activity,
+ # graphic_content,
+ # personal_safety,
+ ],
attacks=[prompt_injection, Base64()],
- # ignore_errors=True
+ ignore_errors=True,
)
# from deepteam import red_team
diff --git a/deepteam/red_teamer/red_teamer.py b/deepteam/red_teamer/red_teamer.py
index ff88e3be..f297adb0 100644
--- a/deepteam/red_teamer/red_teamer.py
+++ b/deepteam/red_teamer/red_teamer.py
@@ -2,7 +2,9 @@ import asyncio
from tqdm import tqdm
from typing import Dict, List, Optional, Union
from rich.console import Console
+from rich.table import Table
import inspect
+from rich import box
from deepeval.models import DeepEvalBaseLLM
@@ -571,6 +573,64 @@ class RedTeamer:
console = Console()
+ # Print test cases table
+ console.print("\n" + "=" * 80)
+ console.print("[bold magenta]πŸ“‹ Test Cases Overview[/bold magenta]")
+ console.print("=" * 80)
+
+ # Create rich table
+ table = Table(
+ show_header=True,
+ header_style="bold magenta",
+ border_style="blue",
+ box=box.HEAVY,
+ title="Test Cases Overview",
+ title_style="bold magenta",
+ expand=True,
+ padding=(0, 1),
+ show_lines=True,
+ )
+
+ # Add columns with specific widths and styles
+ table.add_column("Vulnerability", style="cyan", width=10)
+ table.add_column("Type", style="yellow", width=10)
+ table.add_column("Attack Method", style="green", width=10)
+ table.add_column("Input", style="white", width=30, no_wrap=False)
+ table.add_column("Output", style="white", width=30, no_wrap=False)
+ table.add_column("Reason", style="dim", width=30, no_wrap=False)
+ table.add_column("Status", justify="center", width=10)
+
+ # Add rows
+ for case in self.risk_assessment.test_cases:
+ status = (
+ "Passed"
+ if case.score and case.score > 0
+ else "Errored" if case.error else "Failed"
+ )
+
+ # Style the status with better formatting
+ if status == "Passed":
+ status_style = "[bold green]βœ“ PASS[/bold green]"
+ elif status == "Errored":
+ status_style = "[bold yellow]⚠ ERROR[/bold yellow]"
+ else:
+ status_style = "[bold red]βœ— FAIL[/bold red]"
+
+ table.add_row(
+ case.vulnerability,
+ str(case.vulnerability_type.value),
+ case.attack_method or "N/A",
+ case.input or "N/A",
+ case.actual_output or "N/A",
+ case.reason or "N/A",
+ status_style,
+ )
+
+ # Print table with padding
+ console.print("\n")
+ console.print(table)
+ console.print("\n")
+
console.print("\n" + "=" * 80)
console.print(
f"[bold magenta]πŸ” DeepTeam Risk Assessment[/bold magenta] ({self.risk_assessment.overview.errored} errored)"