From 8dd8f3fa2fe209db36a1dc1bae28e33fa18f2292 Mon Sep 17 00:00:00 2001 From: Denis Shulyaka Date: Sun, 29 Nov 2026 23:13:51 +0300 Subject: [PATCH] Bump openai to 3.60.0 (#195374) --- homeassistant/components/cloud/manifest.json | 2 +- .../components/litellm/manifest.json | 2 +- .../components/llama_cpp/manifest.json | 2 +- .../components/open_router/manifest.json | 2 +- .../components/openai_conversation/entity.py | 7 ++--- .../openai_conversation/manifest.json | 2 +- .../ovhcloud_ai_endpoints/manifest.json | 2 +- homeassistant/package_constraints.txt | 2 +- requirements_all.txt | 2 +- tests/components/litellm/test_init.py | 5 +++- tests/components/litellm/test_stt.py | 2 +- .../components/llama_cpp/test_config_flow.py | 8 ++++-- tests/components/llama_cpp/test_init.py | 2 +- .../openai_conversation/test_config_flow.py | 27 ++++++++++++++----- .../openai_conversation/test_conversation.py | 24 ++++++++++++----- .../openai_conversation/test_stt.py | 9 +++++-- .../openai_conversation/test_tts.py | 7 +++-- 17 files changed, 71 insertions(+), 36 deletions(-) diff --git a/homeassistant/components/cloud/manifest.json b/homeassistant/components/cloud/manifest.json index a53e1c8a8562..3becc39bef52 100644 --- a/homeassistant/components/cloud/manifest.json +++ b/homeassistant/components/cloud/manifest.json @@ -19,6 +19,6 @@ "learn_more_url": "https://support.nabucasa.com/hc/en-us/articles/29718084245149-Speech-to-text-STT" } }, - "requirements": ["hass-nabucasa==2.9.0", "openai==3.26.0"], + "requirements": ["hass-nabucasa==2.9.0", "openai==3.60.0"], "single_config_entry": true } diff --git a/homeassistant/components/litellm/manifest.json b/homeassistant/components/litellm/manifest.json index 8db163e8e721..a0825d66820e 100644 --- a/homeassistant/components/litellm/manifest.json +++ b/homeassistant/components/litellm/manifest.json @@ -11,5 +11,5 @@ "integration_type": "service", "iot_class": "cloud_polling", "quality_scale": "bronze", - "requirements": ["openai==3.26.0"] + "requirements": ["openai==3.60.0"] } diff --git a/homeassistant/components/llama_cpp/manifest.json b/homeassistant/components/llama_cpp/manifest.json index 8744153747cf..b4557212546f 100644 --- a/homeassistant/components/llama_cpp/manifest.json +++ b/homeassistant/components/llama_cpp/manifest.json @@ -11,5 +11,5 @@ "integration_type": "service", "iot_class": "local_polling", "quality_scale": "bronze", - "requirements": ["openai==3.26.0"] + "requirements": ["openai==3.60.0"] } diff --git a/homeassistant/components/open_router/manifest.json b/homeassistant/components/open_router/manifest.json index e2a39259ba1c..0f7de6ad1b78 100644 --- a/homeassistant/components/open_router/manifest.json +++ b/homeassistant/components/open_router/manifest.json @@ -11,5 +11,5 @@ "integration_type": "service", "iot_class": "cloud_polling", "quality_scale": "bronze", - "requirements": ["openai==3.26.0", "python-open-router==0.5.0"] + "requirements": ["openai==3.60.0", "python-open-router==0.5.0"] } diff --git a/homeassistant/components/openai_conversation/entity.py b/homeassistant/components/openai_conversation/entity.py index d4892064152a..e9f5331774f7 100644 --- a/homeassistant/components/openai_conversation/entity.py +++ b/homeassistant/components/openai_conversation/entity.py @@ -645,19 +645,16 @@ class OpenAIBaseLLMEntity(Entity): model=image_model, output_format="png", ) - complexity = None if image_model.startswith("gpt-image-2.6"): match reasoning.get("effort"): case "none" | "minimal": - complexity = "low" + image_tool["complexity"] = "low" case "xhigh" | "max": - complexity = "high" + image_tool["complexity"] = "high" else: # Older image models reject inherited complexity. # More details: https://community.openai.com/t/responses-api-with-gpt-image-2-gives-complexity-low-is-not-supported-after-gpt-image-2-6-launch-with-temporary-hack/1412952/8 reasoning.pop("effort", None) - if complexity is not None: - image_tool["complexity"] = complexity # type: ignore[typeddict-unknown-key] if image_model in ("gpt-image-1", "gpt-image-1.5"): image_tool["input_fidelity"] = "high" tools.append(image_tool) diff --git a/homeassistant/components/openai_conversation/manifest.json b/homeassistant/components/openai_conversation/manifest.json index 5ce53a67aadb..19b47ef02410 100644 --- a/homeassistant/components/openai_conversation/manifest.json +++ b/homeassistant/components/openai_conversation/manifest.json @@ -11,5 +11,5 @@ "integration_type": "service", "iot_class": "cloud_polling", "quality_scale": "bronze", - "requirements": ["openai==3.26.0"] + "requirements": ["openai==3.60.0"] } diff --git a/homeassistant/components/ovhcloud_ai_endpoints/manifest.json b/homeassistant/components/ovhcloud_ai_endpoints/manifest.json index f08322cfab86..c31ca71aaec3 100644 --- a/homeassistant/components/ovhcloud_ai_endpoints/manifest.json +++ b/homeassistant/components/ovhcloud_ai_endpoints/manifest.json @@ -11,5 +11,5 @@ "integration_type": "service", "iot_class": "cloud_polling", "quality_scale": "silver", - "requirements": ["openai==3.26.0"] + "requirements": ["openai==3.60.0"] } diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index a1c58455c359..f01feea6dcc1 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -50,7 +50,7 @@ lru-dict==1.4.1 matter-ble-proxy==0.7.1 matter-python-client==1.6.1 mutagen==1.48.1 -openai==3.26.0 +openai==3.60.0 orjson==3.13.0 packaging>=23.1 paho-mqtt==2.1.0 diff --git a/requirements_all.txt b/requirements_all.txt index e3add7f5f46b..04df9d043f29 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1898,7 +1898,7 @@ open-meteo==1.0.1 # homeassistant.components.open_router # homeassistant.components.openai_conversation # homeassistant.components.ovhcloud_ai_endpoints -openai==3.26.0 +openai==3.60.0 # homeassistant.components.openerz openerz-api==0.3.0 diff --git a/tests/components/litellm/test_init.py b/tests/components/litellm/test_init.py index abc41520ad10..ca484d9fc34f 100644 --- a/tests/components/litellm/test_init.py +++ b/tests/components/litellm/test_init.py @@ -46,7 +46,10 @@ async def test_load_unload_entry( ), ConfigEntryState.SETUP_ERROR, ), - (APIConnectionError(request=None), ConfigEntryState.SETUP_RETRY), + ( + APIConnectionError(request=httpx2.Request("GET", "http://localhost")), + ConfigEntryState.SETUP_RETRY, + ), ], ) async def test_setup_error( diff --git a/tests/components/litellm/test_stt.py b/tests/components/litellm/test_stt.py index 0535a806836d..7cf5c6834fff 100644 --- a/tests/components/litellm/test_stt.py +++ b/tests/components/litellm/test_stt.py @@ -233,7 +233,7 @@ async def test_stt_connection_error_marks_entity_unavailable( """Test connection errors mark the entity unavailable.""" entity = await _setup_stt(hass) mock_openai_client.audio.transcriptions.create = AsyncMock( - side_effect=APIConnectionError(request=None) + side_effect=APIConnectionError(request=httpx2.Request("POST", TEST_URL)) ) result = await entity.async_process_audio_stream( diff --git a/tests/components/llama_cpp/test_config_flow.py b/tests/components/llama_cpp/test_config_flow.py index 3dac6182e2ca..b46c29cd4a92 100644 --- a/tests/components/llama_cpp/test_config_flow.py +++ b/tests/components/llama_cpp/test_config_flow.py @@ -291,7 +291,9 @@ async def test_creating_conversation_subentry_error( """Test creating a conversation subentry handles connection errors.""" with patch( "homeassistant.components.llama_cpp.config_flow.openai.resources.models.AsyncModels.list", - side_effect=openai.APIConnectionError(request=None), + side_effect=openai.APIConnectionError( + request=httpx2.Request(method="GET", url="test") + ), ): result = await hass.config_entries.subentries.async_init( (mock_config_entry.entry_id, "conversation"), @@ -545,7 +547,9 @@ async def test_reconfiguring_conversation_subentry_connection_error( with patch( "openai.resources.models.AsyncModels.list", - side_effect=openai.APIConnectionError(request=None), + side_effect=openai.APIConnectionError( + request=httpx2.Request(method="GET", url="test") + ), ): result = await hass.config_entries.subentries.async_init( (mock_config_entry.entry_id, "conversation"), diff --git a/tests/components/llama_cpp/test_init.py b/tests/components/llama_cpp/test_init.py index c56b59c0e948..f07333501363 100644 --- a/tests/components/llama_cpp/test_init.py +++ b/tests/components/llama_cpp/test_init.py @@ -45,7 +45,7 @@ async def test_setup_unload_entry( ConfigEntryState.SETUP_ERROR, ), ( - openai.APIConnectionError(request=None), + openai.APIConnectionError(request=httpx2.Request(method="GET", url="test")), ConfigEntryState.SETUP_RETRY, ), ], diff --git a/tests/components/openai_conversation/test_config_flow.py b/tests/components/openai_conversation/test_config_flow.py index 11be0aa17281..ff1968d8dfb9 100644 --- a/tests/components/openai_conversation/test_config_flow.py +++ b/tests/components/openai_conversation/test_config_flow.py @@ -629,20 +629,31 @@ async def test_subentry_unsupported_reasoning_effort( @pytest.mark.parametrize( ("side_effect", "error"), [ - (APIConnectionError(request=None), "cannot_connect"), + ( + APIConnectionError( + request=httpx2.Request("GET", "https://api.openai.com/v1/models") + ), + "cannot_connect", + ), ( AuthenticationError( - response=httpx2.Response(status_code=None, request=""), + response=httpx2.Response( + 401, + request=httpx2.Request("GET", "https://api.openai.com/v1/models"), + ), body=None, - message=None, + message="Invalid API key", ), "invalid_auth", ), ( BadRequestError( - response=httpx2.Response(status_code=None, request=""), + response=httpx2.Response( + 400, + request=httpx2.Request("GET", "https://api.openai.com/v1/models"), + ), body=None, - message=None, + message="Bad request", ), "unknown", ), @@ -1796,9 +1807,11 @@ async def test_reconfigure_invalid_auth( "homeassistant.components.openai_conversation.config_flow.openai.resources.models.AsyncModels.list", new_callable=AsyncMock, side_effect=AuthenticationError( - response=httpx2.Response(status_code=None, request=""), + response=httpx2.Response( + 401, request=httpx2.Request("GET", "https://api.openai.com/v1/models") + ), body=None, - message=None, + message="Invalid API key", ), ): result = await hass.config_entries.flow.async_configure( diff --git a/tests/components/openai_conversation/test_conversation.py b/tests/components/openai_conversation/test_conversation.py index d0ce0a742355..5d3eaa67618a 100644 --- a/tests/components/openai_conversation/test_conversation.py +++ b/tests/components/openai_conversation/test_conversation.py @@ -90,29 +90,39 @@ async def test_entity( [ ( RateLimitError( - response=httpx2.Response(status_code=429, request=""), + response=httpx2.Response( + 429, + request=httpx2.Request( + "POST", "https://api.openai.com/v1/responses" + ), + ), body=None, - message=None, + message="Rate limit exceeded", ), "Rate limited or insufficient funds", ), ( AuthenticationError( - response=httpx2.Response(status_code=401, request=""), + response=httpx2.Response( + 401, + request=httpx2.Request( + "POST", "https://api.openai.com/v1/responses" + ), + ), body=None, - message=None, + message="Invalid API key", ), "Error talking to OpenAI", ), ], ) +@pytest.mark.usefixtures("mock_init_component") async def test_error_handling( hass: HomeAssistant, mock_config_entry: MockConfigEntry, - mock_init_component, mock_create_stream: AsyncMock, - exception, - message, + exception: RateLimitError | AuthenticationError, + message: str, ) -> None: """Test that we handle errors when calling completion API.""" mock_create_stream.return_value = [exception] diff --git a/tests/components/openai_conversation/test_stt.py b/tests/components/openai_conversation/test_stt.py index 6fc73b4ac4f9..f789ddf3ed55 100644 --- a/tests/components/openai_conversation/test_stt.py +++ b/tests/components/openai_conversation/test_stt.py @@ -191,9 +191,14 @@ async def test_stt_process_audio_stream_api_error( """Test STT processing audio stream with API errors.""" entity = hass.data[stt.DOMAIN].get_entity("stt.openai_stt") mock_create_transcription.side_effect = RateLimitError( - response=httpx2.Response(status_code=429, request=""), + response=httpx2.Response( + 429, + request=httpx2.Request( + "POST", "https://api.openai.com/v1/audio/transcriptions" + ), + ), body=None, - message=None, + message="Rate limit exceeded", ) metadata = stt.SpeechMetadata( diff --git a/tests/components/openai_conversation/test_tts.py b/tests/components/openai_conversation/test_tts.py index 56a65791bd3a..a83cbc8e9be6 100644 --- a/tests/components/openai_conversation/test_tts.py +++ b/tests/components/openai_conversation/test_tts.py @@ -211,9 +211,12 @@ async def test_tts_error( """Test exception handling during text to speech generation.""" # Mock the OpenAI response stream mock_create_speech.side_effect = RateLimitError( - response=httpx2.Response(status_code=429, request=""), + response=httpx2.Response( + 429, + request=httpx2.Request("POST", "https://api.openai.com/v1/audio/speech"), + ), body=None, - message=None, + message="Rate limit exceeded", ) service_data = {