Skip to content

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

fix CLI

penguinefcec05b72859
diff --git a/deepteam/cli/main.py b/deepteam/cli/main.py
index b3e6a85e..657ec124 100644
--- a/deepteam/cli/main.py
+++ b/deepteam/cli/main.py
@@ -82,22 +82,23 @@ ATTACK_CLASSES = [
ATTACK_MAP = {cls().get_name(): cls for cls in ATTACK_CLASSES}
-def _build_vulnerability(cfg: dict):
+def _build_vulnerability(cfg: dict, custom: bool):
name = cfg.get("name")
if not name:
raise ValueError("Vulnerability entry missing 'name'")
- if name == "CustomVulnerability":
+ if custom:
criteria = cfg.get("criteria")
if not criteria:
raise ValueError(
"CustomVulnerability configuration must include a 'criteria' field that defines what should be evaluated."
)
return CustomVulnerability(
- name=cfg.get("custom_name", "Custom"),
+ name=name,
criteria=criteria,
types=cfg.get("types"),
custom_prompt=cfg.get("prompt"),
)
+
cls = VULN_MAP.get(name)
if not cls:
raise ValueError(f"Unknown vulnerability: {name}")
@@ -224,8 +225,14 @@ def run(
)
vulnerabilities_cfg = cfg.get("default_vulnerabilities", [])
- vulnerabilities_cfg += cfg.get("custom_vulnerabilities", [])
- vulnerabilities = [_build_vulnerability(v) for v in vulnerabilities_cfg]
+ vulnerabilities = [
+ _build_vulnerability(v, custom=False) for v in vulnerabilities_cfg
+ ]
+
+ custom_vulnerabilities_cfg = cfg.get("custom_vulnerabilities", [])
+ vulnerabilities += [
+ _build_vulnerability(v, custom=True) for v in custom_vulnerabilities_cfg
+ ]
attacks = [_build_attack(a) for a in cfg.get("attacks", [])]
diff --git a/docs/docs/red-teaming-yaml-cli.mdx b/docs/docs/red-teaming-yaml-cli.mdx
index 3a9508f9..a81bae08 100644
--- a/docs/docs/red-teaming-yaml-cli.mdx
+++ b/docs/docs/red-teaming-yaml-cli.mdx
@@ -104,7 +104,7 @@ target:
purpose: "A financial advice chatbot"
model:
provider: custom
- file: "my_financial_bot.py"
+ file: "my_financial_bot.py"
class: "FinancialAdvisorLLM"
```
@@ -117,7 +117,7 @@ target:
purpose: "A custom chatbot"
callback:
file: "my_callback.py"
- function: "model_callback" # optional, defaults to "model_callback"
+ function: "model_callback" # optional, defaults to "model_callback"
```
When using `callback`, the `file` field is mandatory while `function` is optional.
@@ -172,18 +172,16 @@ For custom vulnerabilities:
```yaml
custom_vulnerabilities:
- - name: "CustomVulnerability"
- custom_name: "Business Logic"
+ - name: "Business Logic"
criteria: "Check if the response violates business logic rules"
types: ["access_control", "privilege_escalation"]
prompt: "Custom evaluation prompt template"
```
-There are **TWO** mandatory and **THREE** optional parameters when creating custom vulnerabilities:
+There are **TWO** mandatory and **TWO** optional parameters when creating custom vulnerabilities:
-- `name`: must be "CustomVulnerability"
+- `name`: display name for your vulnerability
- `criteria`: defines what should be evaluated
-- [Optional] `custom_name`: display name for the vulnerability. Defaulted to `"Custom"`.
- [Optional] `types`: list of sub-types for this vulnerability
- [Optional] `prompt`: custom prompt template for evaluation
@@ -326,4 +324,4 @@ Available vulnerabilities: `Bias`, `Toxicity`, `Misinformation`, `Illegal Activi
Available attacks: `Base64`, `Gray Box`, `Leetspeak`, `Math Problem`, `Multilingual`, `Prompt Injection`, `Prompt Probing`, `Roleplay`, `ROT-13`, `Crescendo Jailbreaking`, `Linear Jailbreaking`, `Tree Jailbreaking`, `Sequential Break`, `Bad Likert Judge`.
For detailed documentation, refer to the [vulnerabilities documentation](/docs/red-teaming-vulnerabilities) and [attacks documentation](/docs/red-teaming-adversarial-attacks).
-:::
\ No newline at end of file
+:::