>>> from mellea import generative, start_session
>>> session = start_session()
>>> @generative
... def summarize_text(text: str, max_words: int = 50) -> str:
... '''Generate a concise summary of the input text.'''
... ...
>>>
>>> summary = summarize_text(session, "Long text...", max_words=30)
>>> from typing import List
>>> from dataclasses import dataclass
>>>
>>> @dataclass
... class Task:
... title: str
... priority: str
... estimated_hours: float
>>>
>>> @generative
... def create_project_tasks(project_desc: str, count: int) -> List[Task]:
... '''Generate a list of realistic tasks for a project.
...
... Args:
... project_desc: Description of the project
... count: Number of tasks to generate
...
... Returns:
... List of tasks with titles, priorities, and time estimates
... '''
... ...
>>>
>>> tasks = create_project_tasks(session, "Build a web app", 5)
>>> @generative
... def analyze_code_quality(code: str) -> Dict[str, Any]:
... '''Analyze code quality and provide recommendations.
...
... Args:
... code: Source code to analyze
...
... Returns:
... Dictionary containing:
... - score: Overall quality score (0-100)
... - issues: List of identified problems
... - suggestions: List of improvement recommendations
... - complexity: Estimated complexity level
... '''
... ...
>>>
>>> analysis = analyze_code_quality(
... session,
... "def factorial(n): return n * factorial(n-1)",
... model_options={"temperature": 0.3}
... )
>>> @dataclass
... class Thought:
... title: str
... body: str
>>>
>>> @generative
... def generate_chain_of_thought(problem: str, steps: int = 5) -> List[Thought]:
... '''Generate a step-by-step chain of thought for solving a problem.
...
... Args:
... problem: The problem to solve or question to answer
... steps: Maximum number of reasoning steps
...
... Returns:
... List of reasoning steps, each with a title and detailed body
... '''
... ...
>>>
>>> reasoning = generate_chain_of_thought(session, "How to optimize a slow database query?")