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

Free with an account

This part is free. Sign in or create an account to watch it.

Sign up
Tools · 2c

Search the web

So far every tool was our own Python function. This one runs at Google: with one line, capabilities=[WebSearch()], the model may search the web, the search runs inside the same model request, and our code runs nothing for it. The opener asks the bot from the end of 2b, "Did the Lakers win last night?": it searches your email and calendar and, four requests later, says it has no internet access. Then six stops follow the same question: WebSearch is a description, not a search → the framework checks that the model can run it → the request carries google_search beside five function declarations → the answer holds a NativeToolCallPart with two queries, a NativeToolReturnPart and final_result → CallToolsNode walks past the two record parts, with no back arrow → usage counts no searches at all (reported as pydantic/pydantic-ai#15148). With our Reply as the output Gemini sends no sources, so the dependable part of the record is the queries. Then "Is there a Lakers game on Wednesday, and am I free to watch it?": the calendar and email tools cross the line, the search does not; three requests, none of them for the search. Last: how to test a tool that only runs at Google.

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 next3a · Carry the conversation on→