Skip to content

Accrue

Enrich datasets with LLMs. Compose pipelines, run them across thousands of rows, get structured output back.

Install

pip install accrue

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 LLMClient protocol
  • 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_if predicates 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 and tail -f