MObject, Query, Transform, and MObjectProtocol for query/transform workflows.
Defines the MObjectProtocol protocol for objects that can be queried and
transformed by an LLM, and the concrete MObject base class that implements it.
Also provides the Query and Transform [Component](../../core/base#class-component) subtypes, which wrap an
object with a natural-language question or mutation instruction respectively. These
primitives underpin @mify and can be composed directly to build document Q&A
or structured extraction pipelines.
Classes
CLASS Query
A [Component](../../core/base#class-component) that pairs an MObject with a natural-language question.
Wraps the object and its query string into a [TemplateRepresentation](../../core/base#class-templaterepresentation) so the
formatter can render both together in a prompt, optionally forwarding the
object’s tools and fields to the template.
Args:
obj: The object to be queried.query: The natural-language question to ask about the object.
FUNC parts
- list[Component | CBlock]: A list containing the wrapped object.
FUNC format_for_llm
- TemplateRepresentation | str: A
[TemplateRepresentation](../../core/base#class-templaterepresentation)containing - the query string, the wrapped object, and any tools or fields from the
- object’s own representation.
CLASS Transform
A [Component](../../core/base#class-component) that pairs an MObject with a natural-language mutation instruction.
Wraps the object and its transformation description into a
[TemplateRepresentation](../../core/base#class-templaterepresentation) so the formatter can render both together in a prompt,
optionally forwarding the object’s tools and fields to the template.
Args:
obj: The object to be transformed.transformation: The natural-language description of the transformation.
FUNC parts
- list[Component | CBlock]: A list containing the wrapped object.
FUNC format_for_llm
- TemplateRepresentation | str: A
[TemplateRepresentation](../../core/base#class-templaterepresentation)containing - the transformation description, the wrapped object, and any tools or
- fields from the object’s own representation.
CLASS MObjectProtocol
Protocol to describe the necessary functionality of a MObject. Implementers should prefer inheriting from MObject than MObjectProtocol.
Methods:
FUNC parts
- list[Component | CBlock]: The constituent sub-components.
FUNC get_query_object
query: The query string.
- A
Querycomponent wrapping this object and the given - query string.
FUNC get_transform_object
transformation: The transformation description string.
- A
Transformcomponent wrapping this object and the - given transformation description.
FUNC content_as_string
str(self).
Subclasses should override this method.
Returns:
- String representation of this object’s content.
FUNC format_for_llm
[TemplateRepresentation](../../core/base#class-templaterepresentation) uses automatic parsing for tools
and fields. Content is retrieved from content_as_string().
Returns:
- TemplateRepresentation | str: The formatted representation for the
- language model.
CLASS MObject
An extension of [Component](../../core/base#class-component) for adding query and transform operations.
Args:
query_type: TheQuerysubclass to use when constructing query components. Defaults toQuery.transform_type: TheTransformsubclass to use when constructing transform components. Defaults toTransform.
FUNC parts
- list[Component | CBlock]: Always an empty list.
FUNC get_query_object
query: The query string.
- A
Querycomponent wrapping this object and the given - query string.
FUNC get_transform_object
transformation: The transformation description string.
- A
Transformcomponent wrapping this object and the - given transformation description.
FUNC content_as_string
str(self).
Subclasses should override this method.
Returns:
- String representation of this object’s content.
FUNC format_for_llm
[TemplateRepresentation](../../core/base#class-templaterepresentation) uses automatic parsing for tools
and fields. Content is retrieved from content_as_string().
Returns:
- TemplateRepresentation | str: The formatted representation for the
- language model.