Skip to main content
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.
Methods:

FUNC parts

parts(self) -> list[Component | CBlock]
Return the constituent parts of this query component. Returns:
  • list[Component | CBlock]: A list containing the wrapped object.

FUNC format_for_llm

format_for_llm(self) -> TemplateRepresentation | str
Format this query for the language model. Returns:
  • 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.
Methods:

FUNC parts

parts(self) -> list[Component | CBlock]
Return the constituent parts of this transform component. Returns:
  • list[Component | CBlock]: A list containing the wrapped object.

FUNC format_for_llm

format_for_llm(self) -> TemplateRepresentation | str
Format this transform for the language model. Returns:
  • 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

parts(self) -> list[Component | CBlock]
Return a list of parts for this MObject. Returns:
  • list[Component | CBlock]: The constituent sub-components.

FUNC get_query_object

get_query_object(self, query: str) -> Query
Return the instantiated query object. Args:
  • query: The query string.
Returns:
  • A Query component wrapping this object and the given
  • query string.

FUNC get_transform_object

get_transform_object(self, transformation: str) -> Transform
Return the instantiated transform object. Args:
  • transformation: The transformation description string.
Returns:
  • A Transform component wrapping this object and the
  • given transformation description.

FUNC content_as_string

content_as_string(self) -> str
Return the content of this MObject as a plain string. The default value is just str(self). Subclasses should override this method. Returns:
  • String representation of this object’s content.

FUNC format_for_llm

format_for_llm(self) -> TemplateRepresentation | str
Return the template representation used by the formatter. The default [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: The Query subclass to use when constructing query components. Defaults to Query.
  • transform_type: The Transform subclass to use when constructing transform components. Defaults to Transform.
Methods:

FUNC parts

parts(self) -> list[Component | CBlock]
MObject has no parts because of how format_for_llm is defined. Returns:
  • list[Component | CBlock]: Always an empty list.

FUNC get_query_object

get_query_object(self, query: str) -> Query
Return the instantiated query object. Args:
  • query: The query string.
Returns:
  • A Query component wrapping this object and the given
  • query string.

FUNC get_transform_object

get_transform_object(self, transformation: str) -> Transform
Return the instantiated transform object. Args:
  • transformation: The transformation description string.
Returns:
  • A Transform component wrapping this object and the
  • given transformation description.

FUNC content_as_string

content_as_string(self) -> str
Return the content of this MObject as a plain string. The default value is just str(self). Subclasses should override this method. Returns:
  • String representation of this object’s content.

FUNC format_for_llm

format_for_llm(self) -> TemplateRepresentation | str
Return the template representation used by the formatter. The default [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.