You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -194,6 +207,36 @@ Most examples use PydanticAI's `Agent` class, which wraps an LLM with:
194
207
- Output type schemas for structured responses
195
208
- Async/await support for concurrent requests
196
209
210
+
### Tools
211
+
212
+
It's worth noticing that since those are examples, most of them are pretty basic. However, it's easy to add an a tool for given agent. Let's look at **[OCR Parsing](ocr_parsing/) code.
213
+
214
+
Currently the Agent does all the work itself - classifies document, parses the output, does the OCR and so on for every document in the same way. But what if we'd like to have a different behavior based on the document type?
215
+
216
+
```python
217
+
from pydantic_ai import Agent, RunContext
218
+
from my_schemas import OCRInvoiceOutput, ReportOcrOutput
219
+
220
+
# The Agent acts as a router, deciding which tool to call
221
+
# based on the document's visual or textual cues.
222
+
agent = Agent(
223
+
'openai:gpt-5.1',
224
+
system_prompt="Analyze the document and use the appropriate tool for parsing."
0 commit comments