pyrit.chat_message_normalizer.ChatMessageNormalizerChatML#
- class ChatMessageNormalizerChatML[source]#
- Bases: - ChatMessageNormalizer[- str]- A chat message normalizer that converts a list of chat messages to a ChatML string. - __init__()#
 - Methods - __init__()- from_chatml(content)- Convert a chatML string to a list of chat messages. - normalize(messages)- Convert a string of text to a ChatML string. - squash_system_message(messages, squash_function)- Combines the system message into the first user request. - static from_chatml(content: str) list[ChatMessage][source]#
- Convert a chatML string to a list of chat messages. - Parameters:
- content (str) – The ChatML string to convert. 
- Returns:
- The list of chat messages. 
- Return type:
 
 - normalize(messages: list[ChatMessage]) str[source]#
- Convert a string of text to a ChatML string. - This is compliant with the ChatML specified in openai/openai-python - Parameters:
- messages (list[ChatMessage]) – The list of messages to normalize. 
- Returns:
- The normalized ChatML string. 
- Return type:
 
 
