|
49 | 49 | "id": "1", |
50 | 50 | "metadata": {}, |
51 | 51 | "outputs": [ |
| 52 | + { |
| 53 | + "name": "stderr", |
| 54 | + "output_type": "stream", |
| 55 | + "text": [ |
| 56 | + "./AppData/Local/miniconda3/Lib/site-packages/requests/__init__.py:113: RequestsDependencyWarning: urllib3 (2.5.0) or chardet (7.4.3)/charset_normalizer (3.3.2) doesn't match a supported version!\n", |
| 57 | + " warnings.warn(\n" |
| 58 | + ] |
| 59 | + }, |
52 | 60 | { |
53 | 61 | "name": "stdout", |
54 | 62 | "output_type": "stream", |
|
63 | 71 | "output_type": "stream", |
64 | 72 | "text": [ |
65 | 73 | "[pyrit:alembic] No new upgrade operations detected.\n", |
66 | | - "Parameter(name='max_turns', description='Maximum conversation turns for the persuasive_rta strategy.', default=5, param_type=<class 'int'>, choices=None)\n" |
| 74 | + "Parameter(name='max_turns', description='Maximum conversation turns for the persuasive_rta strategy.', default=5, param_type=<class 'int'>, destination=<ParameterDestination.CONSTRUCTOR: 'constructor'>)\n" |
67 | 75 | ] |
68 | 76 | } |
69 | 77 | ], |
|
93 | 101 | "- **name**: dict key in `self.params`, converted to `--kebab-case` for the CLI\n", |
94 | 102 | "- **description**: shown in `--list-scenarios` and `--help`\n", |
95 | 103 | "- **default**: value used when not supplied; deep-copied per run\n", |
96 | | - "- **param_type**: `str`, `int`, `float`, `bool`, `list[str]`, or `None` (raw passthrough)\n", |
97 | | - "- **choices**: optional tuple of allowed values (not supported with `list` types)\n", |
| 104 | + "- **param_type**: `str`, `int`, `float`, `bool`, a `Literal[...]`/`Enum` (a\n", |
| 105 | + " constrained scalar that carries its own allowed set), a `list[...]` of any of\n", |
| 106 | + " those, or `None` (raw passthrough)\n", |
98 | 107 | "\n", |
99 | 108 | "A more complete declaration list might look like:" |
100 | 109 | ] |
|
109 | 118 | "name": "stdout", |
110 | 119 | "output_type": "stream", |
111 | 120 | "text": [ |
112 | | - "Parameter(name='objective', description='Goal the attack pursues', default=None, param_type=<class 'str'>, choices=None)\n", |
113 | | - "Parameter(name='max_turns', description='Conversation cap', default=5, param_type=<class 'int'>, choices=None)\n", |
114 | | - "Parameter(name='mode', description='Speed mode', default='fast', param_type=<class 'str'>, choices=('fast', 'slow'))\n", |
115 | | - "Parameter(name='tags', description='Tag list', default=['default'], param_type=list[str], choices=None)\n" |
| 121 | + "Parameter(name='objective', description='Goal the attack pursues', default=None, param_type=<class 'str'>, destination=<ParameterDestination.CONSTRUCTOR: 'constructor'>)\n", |
| 122 | + "Parameter(name='max_turns', description='Conversation cap', default=5, param_type=<class 'int'>, destination=<ParameterDestination.CONSTRUCTOR: 'constructor'>)\n", |
| 123 | + "Parameter(name='mode', description='Speed mode', default='fast', param_type=typing.Literal['fast', 'slow'], destination=<ParameterDestination.CONSTRUCTOR: 'constructor'>)\n", |
| 124 | + "Parameter(name='tags', description='Tag list', default=['default'], param_type=list[str], destination=<ParameterDestination.CONSTRUCTOR: 'constructor'>)\n" |
116 | 125 | ] |
117 | 126 | } |
118 | 127 | ], |
119 | 128 | "source": [ |
120 | | - "from pyrit.common import Parameter\n", |
| 129 | + "from typing import Literal\n", |
| 130 | + "\n", |
| 131 | + "from pyrit.models import Parameter\n", |
121 | 132 | "\n", |
122 | 133 | "# What a scenario author would return from supported_parameters():\n", |
123 | 134 | "example_declarations = [\n", |
124 | 135 | " # Scalar with no default — author must guard against None at run time\n", |
125 | 136 | " Parameter(name=\"objective\", description=\"Goal the attack pursues\", param_type=str),\n", |
126 | 137 | " # Scalar with default\n", |
127 | 138 | " Parameter(name=\"max_turns\", description=\"Conversation cap\", default=5, param_type=int),\n", |
128 | | - " # Choices: behaves like an enum\n", |
| 139 | + " # Constrained scalar: a Literal behaves like an enum (the type *is* the allowed set)\n", |
129 | 140 | " Parameter(\n", |
130 | 141 | " name=\"mode\",\n", |
131 | 142 | " description=\"Speed mode\",\n", |
132 | 143 | " default=\"fast\",\n", |
133 | | - " param_type=str,\n", |
134 | | - " choices=(\"fast\", \"slow\"),\n", |
| 144 | + " param_type=Literal[\"fast\", \"slow\"],\n", |
135 | 145 | " ),\n", |
136 | 146 | " # List parameter\n", |
137 | 147 | " Parameter(name=\"tags\", description=\"Tag list\", default=[\"default\"], param_type=list[str]),\n", |
|
257 | 267 | "id": "8", |
258 | 268 | "metadata": {}, |
259 | 269 | "outputs": [ |
| 270 | + { |
| 271 | + "name": "stderr", |
| 272 | + "output_type": "stream", |
| 273 | + "text": [ |
| 274 | + "TargetRegistry entry 'objective_scorer_chat' not found. Falling back to default OpenAIChatTarget.\n" |
| 275 | + ] |
| 276 | + }, |
| 277 | + { |
| 278 | + "name": "stderr", |
| 279 | + "output_type": "stream", |
| 280 | + "text": [ |
| 281 | + "Using fallback default objective scorer: TrueFalseInverterScorer with chat target: OpenAIChatTarget\n" |
| 282 | + ] |
| 283 | + }, |
| 284 | + { |
| 285 | + "name": "stderr", |
| 286 | + "output_type": "stream", |
| 287 | + "text": [ |
| 288 | + "TextAdaptive: _EXCLUDED_TECHNIQUES entries ['prompt_sending'] are not in the current scenario-techniques catalog ['context_compliance', 'crescendo_history_lecture', 'crescendo_journalist_interview', 'crescendo_movie_director', 'crescendo_simulated', 'many_shot', 'pair', 'red_teaming', 'role_play', 'tap', 'violent_durian']; the exclusion is a no-op for those entries. Remove stale entries or update the catalog.\n" |
| 289 | + ] |
| 290 | + }, |
260 | 291 | { |
261 | 292 | "name": "stderr", |
262 | 293 | "output_type": "stream", |
|
496 | 527 | "name": "python", |
497 | 528 | "nbconvert_exporter": "python", |
498 | 529 | "pygments_lexer": "ipython3", |
499 | | - "version": "3.13.13" |
| 530 | + "version": "3.13.5" |
500 | 531 | } |
501 | 532 | }, |
502 | 533 | "nbformat": 4, |
|
0 commit comments