Skip to main content
Abstract Formatter interface for rendering components to strings. A Formatter converts Component and CBlock objects into the text strings fed to language model prompts. The single abstract method print encapsulates this rendering contract; concrete subclasses such as ChatFormatter and TemplateFormatter extend it with chat-message and Jinja2-template rendering respectively.

Classes

CLASS Formatter

A Formatter converts Components into strings and parses ModelOutputThunks into Components (or CBlocks).
Methods:

FUNC print

print(self, c: Component | CBlock) -> str
Renders a Component or CBlock into a string suitable for use as model input. Args:
  • c: The component or content block to render.
Returns:
  • The rendered string representation of c.