Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pydantic_ai_slim/pydantic_ai/models/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
UserContent,
UserPromptPart,
)
from ..profiles import ModelProfileSpec
from ..profiles import ModelProfile, ModelProfileSpec
from ..settings import ModelSettings
from ..tools import ToolDefinition
from . import Model, ModelRequestParameters, StreamedResponse
Expand Down Expand Up @@ -111,6 +111,12 @@ def __init__(
stream_function_name = self.stream_function.__name__ if self.stream_function is not None else ''
self._model_name = model_name or f'function:{function_name}:{stream_function_name}'

# Use a default profile that supports JSON schema and object output if none provided
if profile is None:
profile = ModelProfile(
supports_json_schema_output=True,
supports_json_object_output=True,
)
super().__init__(settings=settings, profile=profile)

async def request(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ def return_city_location(messages: list[ModelMessage], _info: AgentInfo) -> Mode
text = '{"city": "Mexico City", "country": "Mexico"}'
return ModelResponse(parts=[TextPart(content=text)])

m = FunctionModel(return_city_location, profile=ModelProfile(supports_json_schema_output=True))
m = FunctionModel(return_city_location)

class CityLocation(BaseModel):
city: str
Expand Down