Your compare_tones runs two agents in parallel. Now you need them in sequence — a pipeline where Stage 1's output feeds Stage 2. What's the business case?
Support tickets. Summarise the issue first, then classify urgency from the summary. One dict back with both — the summary for the Slack notification and the urgency label for routing.
Exactly the right design. ai_pipeline wraps both stages into one function and returns both results:
def ai_pipeline(text: str) -> dict:
summary = summarize_text(text)
urgency = classify_urgency(summary)
return {"summary": summary, "urgency": urgency}Why return the summary too? The caller just needs the urgency for routing.
The summary is useful for the Slack notification — 'High urgency: billing issue, double charge on invoice.' Returning both lets the caller use either. Pipelines should return everything they computed, not just the final output. Here's the full function:
def ai_pipeline(text: str) -> dict:
summary = summarize_text(text)
urgency = classify_urgency(summary)
print(f"Pipeline: [{urgency}] {summary[:50]}")
return {"summary": summary, "urgency": urgency}I'm running an entire support ops workflow — summarise, classify, route — in 20 lines. My SDR team's daily triage meeting is now a Python function.
Almost. The function doesn't route yet — it just returns the dict. The routing logic — if urgency == 'high': send Slack — lives outside the pipeline. Keep business logic separate from AI logic.
I'm chaining these like functions now. Summarise, classify, route. That's a real ops process in Python.
This pipeline is the template for the capstone. The capstone adds extraction (get the Lead record) and sorting (rank by fit tier). The shape is identical — Stage 1, Stage 2, collect results into a dict or list.
summary = summarize_text(text) # Stage 1: compress
urgency = classify_urgency(summary) # Stage 2: label the summary
return {"summary": summary, "urgency": urgency}Pipelines should return everything they computed. The caller picks what it needs:
summary → Slack notification bodyurgency → routing condition (if urgency == 'high': ...)AI pipeline: summarise + classify. Business logic: routing, alerting, updating CRM. Keep them in separate functions — the pipeline produces data, business logic acts on it.
Your compare_tones runs two agents in parallel. Now you need them in sequence — a pipeline where Stage 1's output feeds Stage 2. What's the business case?
Support tickets. Summarise the issue first, then classify urgency from the summary. One dict back with both — the summary for the Slack notification and the urgency label for routing.
Exactly the right design. ai_pipeline wraps both stages into one function and returns both results:
def ai_pipeline(text: str) -> dict:
summary = summarize_text(text)
urgency = classify_urgency(summary)
return {"summary": summary, "urgency": urgency}Why return the summary too? The caller just needs the urgency for routing.
The summary is useful for the Slack notification — 'High urgency: billing issue, double charge on invoice.' Returning both lets the caller use either. Pipelines should return everything they computed, not just the final output. Here's the full function:
def ai_pipeline(text: str) -> dict:
summary = summarize_text(text)
urgency = classify_urgency(summary)
print(f"Pipeline: [{urgency}] {summary[:50]}")
return {"summary": summary, "urgency": urgency}I'm running an entire support ops workflow — summarise, classify, route — in 20 lines. My SDR team's daily triage meeting is now a Python function.
Almost. The function doesn't route yet — it just returns the dict. The routing logic — if urgency == 'high': send Slack — lives outside the pipeline. Keep business logic separate from AI logic.
I'm chaining these like functions now. Summarise, classify, route. That's a real ops process in Python.
This pipeline is the template for the capstone. The capstone adds extraction (get the Lead record) and sorting (rank by fit tier). The shape is identical — Stage 1, Stage 2, collect results into a dict or list.
summary = summarize_text(text) # Stage 1: compress
urgency = classify_urgency(summary) # Stage 2: label the summary
return {"summary": summary, "urgency": urgency}Pipelines should return everything they computed. The caller picks what it needs:
summary → Slack notification bodyurgency → routing condition (if urgency == 'high': ...)AI pipeline: summarise + classify. Business logic: routing, alerting, updating CRM. Keep them in separate functions — the pipeline produces data, business logic acts on it.
Create a free account to get started. Paid plans unlock all tracks.