pyrit.message_normalizer.MessageListNormalizer#

class MessageListNormalizer[source]#

Bases: ABC, Generic[T]

Abstract base class for normalizers that return a list of items.

Subclasses specify the type T (e.g., Message, ChatMessage) that the list contains. T must implement the DictConvertible protocol (have a to_dict() method).

__init__()#

Methods

__init__()

normalize_async(messages)

Normalize the list of messages into a list of items.

normalize_to_dicts_async(messages)

Normalize the list of messages into a list of dictionaries.

abstract async normalize_async(messages: List[Message]) List[T][source]#

Normalize the list of messages into a list of items.

Parameters:

messages – The list of Message objects to normalize.

Returns:

A list of normalized items of type T.

async normalize_to_dicts_async(messages: List[Message]) List[dict[str, Any]][source]#

Normalize the list of messages into a list of dictionaries.

This method uses normalize_async and calls to_dict() on each item.

Parameters:

messages – The list of Message objects to normalize.

Returns:

A list of dictionaries representing the normalized messages.