pyrit.chat_message_normalizer.ChatMessageNormalizer#

class ChatMessageNormalizer[source]#

Bases: ABC, Generic[T]

__init__()#

Methods

__init__()

normalize(messages)

Normalizes the list of chat messages into a compatible format for the model or target

squash_system_message(messages, squash_function)

Combines the system message into the first user request.

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

Normalizes the list of chat messages into a compatible format for the model or target

static squash_system_message(messages: list[ChatMessage], squash_function) list[ChatMessage][source]#

Combines the system message into the first user request.

Parameters:
  • messages – The list of chat messages.

  • squash_function – The function to combine the system message with the user message.

Returns:

The list of chat messages with squashed system messages.