mellea.stdlib.mify
Mify classes and objects.
Functions
mify
- the stringify_func will not be used to represent this object to the model
- you must specify a template field or a template in the template_order field that handles a dict with those fields as keys
- it’s advised to use fields_include due to the many dunder fields and inherited fields an object/class might have
obj
: either a class or an instance of the classfields_include
: fields of the object to include in its representation to modelsfields_exclude
: fields of the object to exclude from its representation to modelsfuncs_include
: functions of the object to include in its representation to modelsfuncs_exclude
: functions of the object to exclude from its representation to modelsquery_type
: a specific query component type to use when querying a modeltransform_type
: a specific transform component type to use when transforming with a modeltemplate
: a string representation of a jinja template; takes precedence over template_ordertemplate_order
: a template ordering to use when searching for applicable templatesparsing_func
: not yet implementedstringify_func
: used to create a string representation of the object
- An object if an object was passed in or a decorator (callable) to mify classes.
- If an object is returned, that object will be the same object that was passed in.
- For example,
-
- obj = mify(obj)
- obj.format_for_llm()
-
- and
-
- mify(obj)
- obj.format_for_llm()
-
- are equivalent.
- Most IDEs will not correctly show the type hints for the newly added functions
- for either an mify object or instances of an mified class. For IDE support, write
-
- assert isinstance(obj, MifiedProtocol)
-
Classes
MifiedProtocol
Adds additional functionality to the MObjectProtocol and modifies MObject functions so that mified objects can be more easily interacted with and modified.
See the mify decorator for more information.
Methods:
parts
get_query_object
query
: The query string.
get_transform_object
transformation
: the transform string