Your classify_urgency uses Literal['high','medium','low']. You can adapt that pattern for lead scoring. What three tiers would you use for a sales pipeline?
Hot, warm, cold. Hot means 'call today', warm means 'follow up this week', cold means 'add to nurture sequence'.
Exactly the right vocabulary. summarize_text compresses the email to two sentences, then a Literal agent classifies the summary. The fit tier label comes from your vocabulary, not the model's:
summary = summarize_text(text)
result = Agent(model, result_type=Literal["hot", "warm", "cold"]).run_sync(summary)
return result.outputWhy summarise first? Why not just classify the raw email?
Two reasons. First, the classifier works on cleaner signal — the core buying intent, not the preamble. Second, longer inputs cost more tokens; two sentences are cheap. Here's the full function:
from typing import Literal
def summarize_and_classify(text: str) -> str:
summary = summarize_text(text)
result = Agent(model, result_type=Literal["hot", "warm", "cold"]).run_sync(summary)
label = result.output
print(f"Lead tier: {label}")
return labelI'm chaining these like functions now. Summarise, then classify. The output of one is the input of the next. That's a real sales process in Python.
That's Week 3's systems moment, and you're arriving early. The pattern you're building — summarise → classify → extract → sort — is the full capstone pipeline. You're three-quarters of the way there.
Point this at my inbound email list and I get a sorted hot/warm/cold call list automatically.
You'll do exactly that in the Week 4 capstone, with a full Lead Pydantic model extracting company name and deal size. summarize_and_classify is the classification stage of that pipeline.
from typing import Literal
summary = summarize_text(text) # Stage 1: compress
label = Agent(model, result_type=Literal["hot", "warm", "cold"]).run_sync(summary).output # Stage 2: labelLiteral for a type-safe label — no .strip().lower() normalisation neededPick vocabulary your sales team already uses. hot/warm/cold maps directly to CRM pipeline stages and is unambiguous to a model.
The classifier processes 2 sentences (the summary), not the full email body. Cheaper and faster than classifying raw emails.
Your classify_urgency uses Literal['high','medium','low']. You can adapt that pattern for lead scoring. What three tiers would you use for a sales pipeline?
Hot, warm, cold. Hot means 'call today', warm means 'follow up this week', cold means 'add to nurture sequence'.
Exactly the right vocabulary. summarize_text compresses the email to two sentences, then a Literal agent classifies the summary. The fit tier label comes from your vocabulary, not the model's:
summary = summarize_text(text)
result = Agent(model, result_type=Literal["hot", "warm", "cold"]).run_sync(summary)
return result.outputWhy summarise first? Why not just classify the raw email?
Two reasons. First, the classifier works on cleaner signal — the core buying intent, not the preamble. Second, longer inputs cost more tokens; two sentences are cheap. Here's the full function:
from typing import Literal
def summarize_and_classify(text: str) -> str:
summary = summarize_text(text)
result = Agent(model, result_type=Literal["hot", "warm", "cold"]).run_sync(summary)
label = result.output
print(f"Lead tier: {label}")
return labelI'm chaining these like functions now. Summarise, then classify. The output of one is the input of the next. That's a real sales process in Python.
That's Week 3's systems moment, and you're arriving early. The pattern you're building — summarise → classify → extract → sort — is the full capstone pipeline. You're three-quarters of the way there.
Point this at my inbound email list and I get a sorted hot/warm/cold call list automatically.
You'll do exactly that in the Week 4 capstone, with a full Lead Pydantic model extracting company name and deal size. summarize_and_classify is the classification stage of that pipeline.
from typing import Literal
summary = summarize_text(text) # Stage 1: compress
label = Agent(model, result_type=Literal["hot", "warm", "cold"]).run_sync(summary).output # Stage 2: labelLiteral for a type-safe label — no .strip().lower() normalisation neededPick vocabulary your sales team already uses. hot/warm/cold maps directly to CRM pipeline stages and is unambiguous to a model.
The classifier processes 2 sentences (the summary), not the full email body. Cheaper and faster than classifying raw emails.
Create a free account to get started. Paid plans unlock all tracks.