Functions
FUNC blockify
blockify is a helper function that turns raw strings into CBlocks.
FUNC get_images_from_component
Component if they are present and a non-empty list, otherwise returns None.
Classes
CLASS CBlock
A CBlock is a block of content that can serve as input to or output from an LLM.
Methods:
FUNC value
FUNC value
CLASS ImageBlock
A ImageBlock represents an image (as base64 PNG).
Methods:
FUNC is_valid_base64_png
FUNC pil_to_base64
FUNC from_pil_image
CLASS ComponentParseError
Raised by Component.parse() when the underlying parsing method throws an exception.
CLASS Component
A Component is a composite data structure that is intended to be represented to an LLM.
Methods:
FUNC parts
Component.
FUNC format_for_llm
Component into a TemplateRepresentation or string.
Returns: a TemplateRepresentation or string
FUNC parse
ModelOutputThunk.
Calls the Component’s underlying ._parse function.
CLASS GenerateType
Used to track what functions can be used to extract a value from a ModelOutputThunk.
CLASS ModelOutputThunk
A ModelOutputThunk is a special type of CBlock that we know came from a model’s output. It is possible to instantiate one without the output being computed yet.
Methods:
FUNC is_computed
FUNC value
FUNC value
FUNC avalue
Exception: Propagates any errors from the underlying inference engine api request.RuntimeError: If called when the ModelOutputThunk’s generate function is not async compatible.
FUNC astream
Exception: Propagates any errors from the underlying inference engine api request.RuntimeError: If called when the ModelOutputThunk’s generate function is not async compatible.
CLASS ContextTurn
A turn of model input and model output.
CLASS Context
A Context is used to track the state of a MelleaSession.
A context is immutable. Every alteration leads to a new context.
Methods:
FUNC from_previous
FUNC reset_to_new
FUNC is_root_node
FUNC previous_node
FUNC node_data
FUNC is_chat_context
FUNC as_list
last_n_components is None, then all components are returned.
FUNC actions_for_available_tools
FUNC last_output
FUNC last_turn
FUNC add
c to this context.