ChatFormatter for converting context histories to chat-message lists.
ChatFormatter is the standard formatter used by mellea’s legacy backends. Its
to_chat_messages method linearises a sequence of [Component](../core/base#class-component) and [CBlock](../core/base#class-cblock)
objects into Message objects with user, assistant, or tool roles,
handling [ModelOutputThunk](../core/base#class-modeloutputthunk) responses, image attachments, and parsed structured
outputs. Concrete backends call this formatter when preparing input for a chat
completion endpoint.
Classes
CLASS ChatFormatter
Formatter used by Legacy backends to format Contexts as Messages.
Methods:
FUNC to_chat_messages
Message with an appropriate role. [ModelOutputThunk](../core/base#class-modeloutputthunk) instances are
treated as assistant responses, while all other [Component](../core/base#class-component) and
[CBlock](../core/base#class-cblock) objects default to the user role. Image attachments and
parsed structured outputs are handled transparently.
Args:
cs: The linearized sequence of context components and code blocks to convert.
- list[Message]: A list of
Messageobjects ready for submission to a chat completion endpoint.