Commands¶
Create reusable text and typed commands (4–6 minutes).
Example¶
from dataclasses import dataclass
from alloy import command
@dataclass
class ArticleSummary:
title: str
key_points: list[str]
@command(output=ArticleSummary)
def summarize_article(text: str) -> str:
return f"Summarize with: title and 3–5 key_points. Article: {text}"
res = summarize_article("Python emphasizes readability and has a vast ecosystem.")
print(res.title)
Expected: a structured object with title
and 3–5 key_points
.
Links (GitHub)¶
- First command
- Async command
- Typed dataclass output
- List of typed items
- Folders: 10-commands · 20-typed
Streaming: see Guide → Streaming (text‑only today).