Skip to main content
NewEpisode 3a is out: Carry the conversation onWatch →
Foundations · 1a

One message in, one typed result out

The assistant handles its first message. The model never answers in prose: Pydantic AI turns your class Reply into a function named final_result, the model calls it, and the arguments are checked into an object your code can use. Eight stops follow one real message: bot.py (32 lines) → the loop that drives a run → UserPromptNode wraps the message into a request → the three things that are sent → Gemini answers with a function call → the arguments are checked against Reply (a string becomes a datetime) → the run ends with three messages in the history → your code holds an object. Then a staged run with a stand-in model shows wrong arguments: the errors go back to the model, it is asked again, and one retry is the default limit. Source pinned at pydantic-ai v2.71.0.

Source code shown in the videos is quoted from pydantic/pydantic-ai (MIT licence), pinned at v2.71.0. This course is not affiliated with or endorsed by Pydantic; the explanations and assignments are original. Course code and assignments · pydantic/pydantic-ai at v2.71.0 · License

Up next1b · Put it on Telegram→