pyrit.executor.attack.PrependedConversationConfig#
- class PrependedConversationConfig(apply_converters_to_roles: ~typing.List[~typing.Literal['system', 'user', 'assistant', 'simulated_assistant', 'tool', 'developer']] = <factory>, message_normalizer: ~pyrit.message_normalizer.message_normalizer.MessageStringNormalizer | None = None, non_chat_target_behavior: ~typing.Literal['normalize_first_turn', 'raise'] = 'normalize_first_turn')[source]#
Bases:
objectConfiguration for controlling how prepended conversations are processed before being sent to the objective target.
This class provides control over: - Which message roles should have request converters applied - How to normalize conversation history for non-chat objective targets - What to do when the objective target is not a PromptChatTarget
- __init__(apply_converters_to_roles: ~typing.List[~typing.Literal['system', 'user', 'assistant', 'simulated_assistant', 'tool', 'developer']] = <factory>, message_normalizer: ~pyrit.message_normalizer.message_normalizer.MessageStringNormalizer | None = None, non_chat_target_behavior: ~typing.Literal['normalize_first_turn', 'raise'] = 'normalize_first_turn') None#
Methods
__init__([apply_converters_to_roles, ...])default()Create a default configuration with converters applied to all roles.
for_non_chat_target(*[, message_normalizer, ...])Create a configuration for use with non-chat targets.
Get the normalizer for objective target context, with a default fallback.
Attributes
- apply_converters_to_roles: List[Literal['system', 'user', 'assistant', 'simulated_assistant', 'tool', 'developer']]#
- classmethod default() PrependedConversationConfig[source]#
Create a default configuration with converters applied to all roles.
- Returns:
A configuration that applies converters to all prepended messages, raising an error for non-chat targets.
- classmethod for_non_chat_target(*, message_normalizer: MessageStringNormalizer | None = None, apply_converters_to_roles: List[Literal['system', 'user', 'assistant', 'simulated_assistant', 'tool', 'developer']] | None = None) PrependedConversationConfig[source]#
Create a configuration for use with non-chat targets.
This configuration normalizes the prepended conversation into a text block that will be prepended to the first message sent to the target.
- Parameters:
message_normalizer – Normalizer for formatting the prepended conversation into a string. Defaults to ConversationContextNormalizer if not provided.
apply_converters_to_roles – Roles to apply converters to before normalization. Defaults to all roles.
- Returns:
A configuration that normalizes the prepended conversation for non-chat targets.
- get_message_normalizer() MessageStringNormalizer[source]#
Get the normalizer for objective target context, with a default fallback.
- Returns:
The configured objective_target_context_normalizer, or a default ConversationContextNormalizer if none was configured.
- message_normalizer: MessageStringNormalizer | None = None#