Component. A Component is a structured object that represents a unit of interaction with an LLM. The Mellea stdlib contains a set of useful components, but you can also define your own. We have already seen some components — Instruction and Requirement are both Components.
Components are composite data structures; that is, a Component can be made up of many other parts. Each of those parts is either a CBlock or another Component. CBlocks, or “content blocks”, are an atomic unit of text or data. CBlocks hold raw text (or sometimes parsed representations) and can be used as leaves in the Component DAG.
Backends are the engine that actually run the LLM. Backends consume Components, format the Component, pass the formatted input to an LLM, and return model outputs, which are then parsed back into CBlocks or Components.
During the course of an interaction with an LLM, several Components and CBlocks may be created. Logic for handling this trace of interactions is provided by a Context object. Some book-keeping needs to be done in order for Contexts to approporiately handle a trace of Components and CBlocks. The MelleaSession class, which is created by mellea.start_session(), does this book-keeping a simple wrapper around Contexts and Backends.
When we call m.instruct(), the MelleaSession.instruct method creates a component called an Instruction. Instructions are part of the Mellea standard library.
So far we have seen Instructions with descriptions and requirements, but an Instruction can also have in-context learning examples and grounding_context (for RAG):
- Instructions, which we have already seen.
- Requirements, which we have already seen and will continue to use heavily throughout the remainder of the tutorial.
- Generative Slots, which treat LLM calls as functions.
- MObjects, which help with context engineering for tool use by placing tools next to the data that those tools most reasonably operate over.
