This directory contains examples of using MObjects (Mellea Objects) - structured data types that work seamlessly with LLMs.
Demonstrates using table MObjects for structured data manipulation.
Key Features:
- Creating and querying tables
- Table transformations
- Structured data operations
- Type-safe table manipulation
- Structured Data: Working with tables and structured formats
- Query Operations: Asking questions about data
- Transformations: Modifying data based on instructions
- Type Safety: Maintaining structure through operations
- LLM Integration: Using LLMs to work with structured data
from mellea.stdlib.components import Table
from mellea import start_session
# Create a table
table = Table(data=[
{"name": "Alice", "age": 30, "city": "NYC"},
{"name": "Bob", "age": 25, "city": "SF"},
])
m = start_session()
# Query the table
result = m.query(table, "What is the average age?")
# Transform the table
new_table = m.transform(table, "Add a column for country (USA)")Mellea provides several MObject types:
- Table: Tabular data with rows and columns
- Document: Text documents with metadata
- RichDocument: Documents with rich formatting
- Custom MObjects via
@mify
Ask questions about the data without modifying it:
answer = m.query(mobject, "What is the total?")Modify the data based on instructions:
new_mobject = m.transform(mobject, "Sort by date descending")Perform operations that may have side effects:
result = m.execute(mobject, "Calculate statistics")- See
mellea/stdlib/components/mobject.pyfor MObject base class - See
mellea/stdlib/components/docs/for document MObjects - See
mify/for creating custom MObjects - See
notebooks/table_mobject.ipynbfor interactive examples