Accrue¶
Enrich datasets with LLMs. Compose pipelines, run them across thousands of rows, get structured output back.
Install¶
Python 3.10+. Set OPENAI_API_KEY to get started. Optional extras: accrue[anthropic], accrue[google], and accrue[ui] for the Accrue Watch dashboard.
Example¶
from accrue import Pipeline, LLMStep
pipeline = Pipeline([
LLMStep("analyze", fields={
"market_size": "Estimate total addressable market in billions USD",
"risk_level": {
"prompt": "Assess investment risk",
"enum": ["Low", "Medium", "High"],
},
})
])
result = pipeline.run([
{"company": "Stripe", "sector": "Fintech"},
{"company": "Notion", "sector": "Productivity"},
])
print(result.data) # Enriched data with new fields
print(result.cost) # Token usage breakdown
Features¶
- Multi-step pipelines -- Chain LLM steps, function steps, and conditional logic into DAGs
- Provider-agnostic -- OpenAI, Anthropic, and Google via a clean
LLMClientprotocol - Field specs -- Prompt, type, format, enum, examples, bad_examples, and default per output field
- Structured output -- Pydantic validation with automatic retries on parse failure
- Caching -- SQLite-backed input-hash cache so re-runs skip completed work
- Batch API --
LLMStep(batch=True)for high-volume jobs at 50% cost via OpenAI and Anthropic batch endpoints - Grounding -- Web search grounding with citations via
LLMStep(grounding=True) - Attachments --
LLMStep(attachments="column")sends a row's PDFs to the model (Anthropic, OpenAI, Gemini) - Conditional steps --
run_if/skip_ifpredicates for per-row branching - Dry-run + cost preview --
pipeline.plan(df)previews prompts, schemas, and sample outputs and estimates the full-run cost before you spend - Hooks and observability -- Progress callbacks, cost tracking, checkpoint recovery
- Run logs --
run(..., run_log=True)streams the run as append-only JSONL (contract v1) for dashboards andtail -f
Quick Links¶
- Getting Started -- Installation, first pipeline, core concepts
- Guides -- Field specs, caching, batch API, grounding, attachments, conditional steps, providers
- Cookbook -- Real-world examples and patterns
- API Reference -- Full class and method reference