Skip to content
Merged
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
6 changes: 3 additions & 3 deletions src/mistralai/extra/utils/response_format.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from pydantic import BaseModel
from typing import TypeVar, Any, Type
from typing import TypeVar, Any, Type, Dict
from ...models import JSONSchema, ResponseFormat
from ._pydantic_helper import rec_strict_json_schema

CustomPydanticModel = TypeVar("CustomPydanticModel", bound=BaseModel)


def response_format_from_pydantic_model(
model: type[CustomPydanticModel],
model: Type[CustomPydanticModel],
) -> ResponseFormat:
"""Generate a strict JSON schema from a pydantic model."""
model_schema = rec_strict_json_schema(model.model_json_schema())
Expand All @@ -18,7 +18,7 @@ def response_format_from_pydantic_model(


def pydantic_model_from_json(
json_data: dict[str, Any], pydantic_model: Type[CustomPydanticModel]
json_data: Dict[str, Any], pydantic_model: Type[CustomPydanticModel]
) -> CustomPydanticModel:
"""Parse a JSON schema into a pydantic model."""
return pydantic_model.model_validate(json_data)