-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Initial Checks
- I confirm that I'm using the latest version of Pydantic AI
- I confirm that I searched for my issue in https://github.com/pydantic/pydantic-ai/issues before opening this issue
Description
# %%
from pydantic import BaseModel
from pydantic_ai import Agent, StructuredDict
class Tire(BaseModel):
brand: str
class Car(BaseModel):
tires: list[Tire]
car_schema = Car.model_json_schema()
structured_dict = StructuredDict(car_schema)
print(structured_dict)
agent = Agent("gpt-4o-mini", output_type=structured_dict)
result = agent.run("What is the make of the car?")
# %%
import json
print(json.dumps(car_schema, indent=4))
{
"$defs": {
"Tire": {
"properties": {
"brand": {
"title": "Brand",
"type": "string"
}
},
"required": [
"brand"
],
"title": "Tire",
"type": "object"
}
},
"properties": {
"tires": {
"items": {
"$ref": "#/$defs/Tire"
},
"title": "Tires",
"type": "array"
}
},
"required": [
"tires"
],
"title": "Car",
"type": "object"
But run()
crashes with
KeyError: '#/$defs/Tire'
Example Code
Python, Pydantic AI & LLM client version
0.6.0, python 3.12
matwasilewski
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working