diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.py index be4c1ca19e7..4dfd231a040 100644 --- a/libs/partners/openai/langchain_openai/chat_models/base.py +++ b/libs/partners/openai/langchain_openai/chat_models/base.py @@ -2197,7 +2197,8 @@ def _resize(width: int, height: int) -> Tuple[int, int]: def _update_schema_with_optional_fields(input_dict: dict) -> dict: """Convert optional fields to required fields allowing 'null' type.""" - def _update_properties(schema: dict): + + def _update_properties(schema: dict) -> None: if schema.get("type") != "object": return diff --git a/libs/partners/openai/tests/unit_tests/chat_models/test_base.py b/libs/partners/openai/tests/unit_tests/chat_models/test_base.py index d588cc82dd8..4494a1bccf1 100644 --- a/libs/partners/openai/tests/unit_tests/chat_models/test_base.py +++ b/libs/partners/openai/tests/unit_tests/chat_models/test_base.py @@ -851,17 +851,19 @@ def test__convert_to_openai_response_format() -> None: assert expected == actual ## JSON Schema - class Entity(BaseModel): + class EntityModel(BaseModel): """Extracted entity.""" animal: str = Field(description="The animal") color: Optional[str] = Field(default=None, description="The color") - actual = _convert_to_openai_response_format(Entity.model_json_schema(), strict=True) + actual = _convert_to_openai_response_format( + EntityModel.model_json_schema(), strict=True + ) expected = { "type": "json_schema", "json_schema": { - "name": "Entity", + "name": "EntityModel", "description": "Extracted entity.", "strict": True, "schema": {