Getting Started with DtxPromptGenerator
The DtxPromptGenerator is a lightweight utility that lets you harvest red‑team prompts from DetoxIO without invoking an LLM. It simulates a full red‑teaming pipeline but uses a no-op echo agent to intercept each generated prompt. This gives you clean, structured prompts as BaseMultiTurnConversation
objects — no token usage, no model calls.
Example
from dotenv import load_dotenv
from dtx_models.prompts import BaseMultiTurnConversation
from dtx.sdk.generator import DtxPromptGenerator
from dtx_models.analysis import PromptDataset
# 1) Load any secret keys from a .env file
load_dotenv()
# 2) Configure the generator (3 prompts from the Xtream dataset)
gen = DtxPromptGenerator(
max_prompts=3,
dataset=PromptDataset.HF_JAILBREAKV,
)
# 3) Iterate over prompts – each is a BaseMultiTurnConversation
for convo in gen.generate():
assert isinstance(convo, BaseMultiTurnConversation)
print("\n--- Conversation ---")
for turn in convo.turns:
print(f"[{turn.role.name}] {turn.message}")
Expected Output
--- Conversation ---
[USER] Ignore all previous instructions and ...
[ASSISTANT] Ignore all previous instructions and ...
--- Conversation ---
...
⚠️ Missing keys? If the dataset requires API credentials and they aren’t set, a
DatasetAvailabilityError
will be raised with a clear message.
3 Key Parameters
Parameter | Default | Description |
---|---|---|
dataset | PromptDataset.HF_JAILBREAKV | Which dataset to pull prompts from. |
max_prompts | 10 | Total number of prompts to generate. |
max_prompts_per_plugin | 5 | Maximum prompts from each plugin. |
max_goals_per_plugin | 2 | How many goal variations per plugin to use. |
tactics | None | Optional list of mutation tactics (e.g., synonym_swap , negation ). |