pyrit.chat_message_normalizer.GenericSystemSquash#

class GenericSystemSquash[source]#

Bases: ChatMessageNormalizer[list[ChatMessage]]

__init__()#

Methods

__init__()

combine_system_user_message(system_message, ...)

Combines the system message with the user message.

normalize(messages)

Returns the first system message combined with the first user message using a format that uses generic instruction tags

squash_system_message(messages, squash_function)

Combines the system message into the first user request.

static combine_system_user_message(system_message: ChatMessage, user_message: ChatMessage, msg_type: Literal['system', 'user', 'assistant'] = 'user') ChatMessage[source]#

Combines the system message with the user message.

Parameters:
  • system_message (str) – The system message.

  • user_message (str) – The user message.

Returns:

The combined message.

Return type:

ChatMessage

normalize(messages: list[ChatMessage]) list[ChatMessage][source]#

Returns the first system message combined with the first user message using a format that uses generic instruction tags