1. Building blocks
  2. Workflows

A workflow says which steps run and in what order. The function body only connects steps; the work happens inside them, when a run starts.

import avalanche as ava


@ava.workflow(input=InvoiceInput)
def process_invoice():
    return (
        (text := read_document(ava.input.text))
        >> (extract_invoice(text) & categorize(text))
        >> build_entry()
    )
Rendering diagram…

​
Connect steps

WriteMeaning
a() >> b()Run a, then b. b receives what a returned.
a() & b()Run a and b side by side. Always put the group in parentheses.
x := a()Name a step’s output to pass it to more than one step.
b(x)Pass a named output as an argument.
ava.input.fieldOne field of the run input.

Calling a step inside a workflow does not run it. It adds the step to the graph and returns a placeholder for its future output.

​
The steps you connect

StepDecoratorUse it for
Python step@ava.stepRules, calculations, API calls, saving results
Agent step@ava.agent_stepReading, research, drafting, extraction
Classifier step@ava.classifier_stepLabels, yes/no probabilities, scores

​
Options

@ava.workflow(
    input=InvoiceInput,        # typed run input
    cron="0 6 * * 1",          # run on a schedule
    webhook=True,              # start a run from an HTTP request
    agent_defaults={...},      # one runtime for every agent step
    classifier_defaults={...}, # one provider for every classifier step
)
def process_invoice(): ...
OptionWhat it does
inputA model that every run’s input is checked against.
cronA cron expression. The workflow then has a schedule.
webhookTrue, or ava.Webhook(path=...). The workflow then has a URL that starts runs.
keyInput fields that identify a run, such as ("invoice_id",). One run per key.
agent_defaultsThe runtime agent steps use unless they set their own.
classifier_defaultsThe provider, model and timeout classifier steps use.

​
In the UI

A workflow graph with four steps

Each step is a card. Agent and classifier steps are labelled.