diff --git a/pydantic_ai_slim/pydantic_ai/profiles/google.py b/pydantic_ai_slim/pydantic_ai/profiles/google.py index 9178d7dd43..3859d76347 100644 --- a/pydantic_ai_slim/pydantic_ai/profiles/google.py +++ b/pydantic_ai_slim/pydantic_ai/profiles/google.py @@ -49,7 +49,6 @@ def transform(self, schema: JsonSchema) -> JsonSchema: ) schema.pop('title', None) - schema.pop('default', None) schema.pop('$schema', None) if (const := schema.pop('const', None)) is not None: # Gemini doesn't support const, but it does support enum with a single value diff --git a/tests/models/test_gemini.py b/tests/models/test_gemini.py index 0b95bedeb5..7d628df31a 100644 --- a/tests/models/test_gemini.py +++ b/tests/models/test_gemini.py @@ -194,7 +194,7 @@ async def test_require_response_tool(allow_model_requests: None): async def test_json_def_replaced(allow_model_requests: None): class Axis(BaseModel): - label: str + label: str = Field(default='', description='The label of the axis') class Chart(BaseModel): x_axis: Axis @@ -213,8 +213,14 @@ class Locations(BaseModel): { '$defs': { 'Axis': { - 'properties': {'label': {'title': 'Label', 'type': 'string'}}, - 'required': ['label'], + 'properties': { + 'label': { + 'default': '', + 'description': 'The label of the axis', + 'title': 'Label', + 'type': 'string', + } + }, 'title': 'Axis', 'type': 'object', }, @@ -268,17 +274,27 @@ class Locations(BaseModel): 'items': { 'properties': { 'lat': {'type': 'number'}, - 'lng': {'type': 'number'}, + 'lng': {'default': 1.1, 'type': 'number'}, 'chart': { 'properties': { 'x_axis': { - 'properties': {'label': {'type': 'string'}}, - 'required': ['label'], + 'properties': { + 'label': { + 'default': '', + 'description': 'The label of the axis', + 'type': 'string', + } + }, 'type': 'object', }, 'y_axis': { - 'properties': {'label': {'type': 'string'}}, - 'required': ['label'], + 'properties': { + 'label': { + 'default': '', + 'description': 'The label of the axis', + 'type': 'string', + } + }, 'type': 'object', }, },