Tutorial: Mifying Legacy Code
Concept overview: MObjects and mify explains the design and trade-offs.
This tutorial shows how to make existing Python objects queryable and transformable
by the LLM using @mify — without changing their Python interface or behaviour.
By the end you will have covered:
- Applying
@mifyto an existing class m.query()— ask questions about an objectm.transform()— produce a transformed version of an object- Controlling which fields and methods the LLM sees
- Using
stringify_funcfor custom text representations
Prerequisites: Tutorial 01 complete,
pip install mellea, Ollama running locally with granite4.1:3b downloaded.
The scenario
You have a CustomerRecord class — existing code that you cannot rewrite. You want
to start asking the LLM questions about individual records and generating
personalised summaries.
class CustomerRecord:
def __init__(self, name: str, last_purchase: str, spend_ytd: float):
self.name = name
self.last_purchase = last_purchase
self.spend_ytd = spend_ytd