extract_contact gave you one model with two fields. A real client triage needs more: category, urgency, a one-line summary. What's the limit on Pydantic model fields?
I assumed there was a practical limit — like after five fields the model starts guessing. Is that true?
Models handle five, ten, fifteen fields reliably when the prompt context is clear. The constraint is your schema design, not the model's capacity. More fields mean more for the model to fill — so keep each field focused and named clearly:
from pydantic import BaseModel
class Ticket(BaseModel):
category: str
urgency: str
one_line_summary: strShould urgency be a str or a Literal? It seems like it should be constrained.
Good instinct. In production you'd use Literal["high","medium","low"] on the field. In this lesson, str keeps the model definition readable so the three-field pattern is the focus. The Literal upgrade is a one-word change once the structure is working.
def triage_ticket(text: str) -> dict:
result = Agent(model, result_type=Ticket).run_sync(text)
data = result.output.model_dump()
return dataThree fields, one call, structured dict output. That's a proper support ticket triage. I could pipe this straight into a Sheets row.
And that's exactly what Week 4's automation lessons do. The AI extracts structure; the automation layer writes it somewhere useful.
I went from free text to a typed three-field dict. No regex, no splitting, no parsing logic.
The pattern scales: add a budget_flag: bool field, a client_name: str field, whatever your workflow needs. The model fills the schema; you decide what the schema is.
Add as many fields as your workflow needs — each with a clear, descriptive name:
from pydantic import BaseModel
class Ticket(BaseModel):
category: str
urgency: str
one_line_summary: str
result = Agent(model, result_type=Ticket).run_sync(text)
data = result.output.model_dump()
# {'category': '...', 'urgency': '...', 'one_line_summary': '...'}one_line_summary is clearer to the model than summary or s.urgency: str works. Upgrade to Literal["high","medium","low"] when you need type-level enforcement.Each field is filled independently from the prompt context.
extract_contact gave you one model with two fields. A real client triage needs more: category, urgency, a one-line summary. What's the limit on Pydantic model fields?
I assumed there was a practical limit — like after five fields the model starts guessing. Is that true?
Models handle five, ten, fifteen fields reliably when the prompt context is clear. The constraint is your schema design, not the model's capacity. More fields mean more for the model to fill — so keep each field focused and named clearly:
from pydantic import BaseModel
class Ticket(BaseModel):
category: str
urgency: str
one_line_summary: strShould urgency be a str or a Literal? It seems like it should be constrained.
Good instinct. In production you'd use Literal["high","medium","low"] on the field. In this lesson, str keeps the model definition readable so the three-field pattern is the focus. The Literal upgrade is a one-word change once the structure is working.
def triage_ticket(text: str) -> dict:
result = Agent(model, result_type=Ticket).run_sync(text)
data = result.output.model_dump()
return dataThree fields, one call, structured dict output. That's a proper support ticket triage. I could pipe this straight into a Sheets row.
And that's exactly what Week 4's automation lessons do. The AI extracts structure; the automation layer writes it somewhere useful.
I went from free text to a typed three-field dict. No regex, no splitting, no parsing logic.
The pattern scales: add a budget_flag: bool field, a client_name: str field, whatever your workflow needs. The model fills the schema; you decide what the schema is.
Add as many fields as your workflow needs — each with a clear, descriptive name:
from pydantic import BaseModel
class Ticket(BaseModel):
category: str
urgency: str
one_line_summary: str
result = Agent(model, result_type=Ticket).run_sync(text)
data = result.output.model_dump()
# {'category': '...', 'urgency': '...', 'one_line_summary': '...'}one_line_summary is clearer to the model than summary or s.urgency: str works. Upgrade to Literal["high","medium","low"] when you need type-level enforcement.Each field is filled independently from the prompt context.
Create a free account to get started. Paid plans unlock all tracks.