Bump openai to 3.10.0 (#181779)

This commit is contained in:
Denis Shulyaka
2026-09-10 14:08:07 +02:00
committed by GitHub
parent d1d6e9bd97
commit 689a5d6103
18 changed files with 42 additions and 25 deletions
+1 -1
View File
@@ -19,6 +19,6 @@
"learn_more_url": "https://support.nabucasa.com/hc/en-us/articles/29718084245149-Speech-to-text-STT"
}
},
"requirements": ["hass-nabucasa==2.7.0", "openai==2.45.0"],
"requirements": ["hass-nabucasa==2.7.0", "openai==3.10.0"],
"single_config_entry": true
}
@@ -1,7 +1,7 @@
"""Config flow for LiteLLM integration."""
import logging
from typing import Any, override
from typing import Any, cast, override
from openai import AsyncOpenAI, AuthenticationError, OpenAIError, PermissionDeniedError
import voluptuous as vol
@@ -65,7 +65,8 @@ async def _get_models(hass: HomeAssistant, url: str, api_key: str | None) -> lis
client = AsyncOpenAI(
base_url=url,
api_key=api_key or PLACEHOLDER_API_KEY,
http_client=get_async_client(hass),
# Legacy HTTPX clients are supported at runtime only.
http_client=cast(Any, get_async_client(hass)),
)
try:
return [
@@ -1,7 +1,7 @@
"""Coordinator for the LiteLLM integration."""
from datetime import timedelta
from typing import override
from typing import Any, cast, override
from openai import AsyncOpenAI, AuthenticationError, OpenAIError, PermissionDeniedError
@@ -40,7 +40,8 @@ class LiteLLMDataUpdateCoordinator(DataUpdateCoordinator[None]):
self.client = AsyncOpenAI(
base_url=config_entry.data[CONF_URL],
api_key=config_entry.data.get(CONF_API_KEY) or PLACEHOLDER_API_KEY,
http_client=get_async_client(hass),
# Legacy HTTPX clients are supported at runtime only.
http_client=cast(Any, get_async_client(hass)),
)
@override
@@ -9,5 +9,5 @@
"integration_type": "service",
"iot_class": "cloud_polling",
"quality_scale": "bronze",
"requirements": ["openai==2.45.0"]
"requirements": ["openai==3.10.0"]
}
+2 -1
View File
@@ -62,7 +62,8 @@ async def async_create_client(
client = openai.AsyncOpenAI(
api_key=api_key,
base_url=config_entry_data[CONF_BASE_URL],
http_client=get_async_client(hass),
# Legacy HTTPX clients are supported at runtime only.
http_client=cast(Any, get_async_client(hass)),
)
# Cache current platform data which gets added to each request
# (caching done by library)
@@ -9,5 +9,5 @@
"integration_type": "service",
"iot_class": "local_polling",
"quality_scale": "bronze",
"requirements": ["openai==2.45.0"]
"requirements": ["openai==3.10.0"]
}
@@ -1,5 +1,7 @@
"""The OpenRouter integration."""
from typing import Any, cast
from openai import AsyncOpenAI, AuthenticationError, OpenAIError
from homeassistant.config_entries import ConfigEntry
@@ -20,7 +22,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: OpenRouterConfigEntry) -
client = AsyncOpenAI(
base_url="https://openrouter.ai/api/v1",
api_key=entry.data[CONF_API_KEY],
http_client=get_async_client(hass),
# Legacy HTTPX clients are supported at runtime only.
http_client=cast(Any, get_async_client(hass)),
)
# Cache current platform data which gets added to each request
@@ -9,5 +9,5 @@
"integration_type": "service",
"iot_class": "cloud_polling",
"quality_scale": "bronze",
"requirements": ["openai==2.45.0", "python-open-router==0.4.0"]
"requirements": ["openai==3.10.0", "python-open-router==0.4.0"]
}
@@ -2,6 +2,7 @@
from pathlib import Path
from types import MappingProxyType
from typing import Any, cast
import openai
from openai.types.images_response import ImagesResponse
@@ -282,7 +283,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: OpenAIConfigEntry) -> bo
"""Set up OpenAI Conversation from a config entry."""
client = openai.AsyncOpenAI(
api_key=entry.data[CONF_API_KEY],
http_client=get_async_client(hass),
# Legacy HTTPX clients are supported at runtime only.
http_client=cast(Any, get_async_client(hass)),
)
# Cache current platform data which gets added to each request
@@ -290,7 +292,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: OpenAIConfigEntry) -> bo
_ = await hass.async_add_executor_job(client.platform_headers)
try:
await hass.async_add_executor_job(client.with_options(timeout=10.0).models.list)
await client.models.list(timeout=10.0)
except openai.AuthenticationError as err:
raise ConfigEntryAuthFailed(err) from err
except openai.OpenAIError as err:
@@ -140,7 +140,7 @@ class OpenAITaskEntity(
else:
mime_type = "image/png"
if hasattr(image_call, "size") and (size := image_call.size):
if size := image_call.size:
width, height = tuple(size.split("x"))
else:
width, height = None, None
@@ -3,7 +3,7 @@
from collections.abc import Mapping
import json
import logging
from typing import Any, override
from typing import Any, cast, override
import openai
from probatio import to_openapi
@@ -117,7 +117,9 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> None:
Data has the keys from STEP_USER_DATA_SCHEMA with values provided by the user.
"""
client = openai.AsyncOpenAI(
api_key=data[CONF_API_KEY], http_client=get_async_client(hass)
api_key=data[CONF_API_KEY],
# Legacy HTTPX clients are supported at runtime only.
http_client=cast(Any, get_async_client(hass)),
)
await client.models.list(timeout=10.0)
@@ -651,7 +653,7 @@ class OpenAISubentryFlowHandler(ConfigSubentryFlow):
if zone_home is not None:
client = openai.AsyncOpenAI(
api_key=self._get_entry().data[CONF_API_KEY],
http_client=get_async_client(self.hass),
http_client=cast(Any, get_async_client(self.hass)),
)
location_schema = vol.Schema(
{
@@ -9,5 +9,5 @@
"integration_type": "service",
"iot_class": "cloud_polling",
"quality_scale": "bronze",
"requirements": ["openai==2.45.0"]
"requirements": ["openai==3.10.0"]
}
@@ -1,5 +1,7 @@
"""The OVHcloud AI Endpoints integration."""
from typing import Any, cast
from openai import (
AsyncOpenAI,
AuthenticationError,
@@ -27,7 +29,8 @@ def _create_client(hass: HomeAssistant, api_key: str) -> AsyncOpenAI:
return AsyncOpenAI(
base_url=BASE_URL,
api_key=api_key,
http_client=get_async_client(hass),
# Legacy HTTPX clients are supported at runtime only.
http_client=cast(Any, get_async_client(hass)),
)
@@ -9,5 +9,5 @@
"integration_type": "service",
"iot_class": "cloud_polling",
"quality_scale": "silver",
"requirements": ["openai==2.45.0"]
"requirements": ["openai==3.10.0"]
}
+1 -1
View File
@@ -47,7 +47,7 @@ ifaddr==0.2.0
Jinja2==3.1.6
lru-dict==1.4.1
mutagen==1.48.1
openai==2.45.0
openai==3.10.0
orjson==3.11.9
packaging>=23.1
paho-mqtt==2.1.0
+1 -1
View File
@@ -1821,7 +1821,7 @@ open-meteo==0.3.2
# homeassistant.components.open_router
# homeassistant.components.openai_conversation
# homeassistant.components.ovhcloud_ai_endpoints
openai==2.45.0
openai==3.10.0
# homeassistant.components.openerz
openerz-api==0.3.0
@@ -1,6 +1,6 @@
"""Tests helpers."""
from collections.abc import Generator
from collections.abc import AsyncGenerator, Generator
from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch
@@ -122,13 +122,15 @@ async def mock_config_entry_with_reasoning_model(
@pytest.fixture
async def mock_init_component(
hass: HomeAssistant, mock_config_entry: MockConfigEntry
) -> None:
) -> AsyncGenerator[None]:
"""Initialize integration."""
with patch(
"openai.resources.models.AsyncModels.list",
new_callable=AsyncMock,
):
assert await async_setup_component(hass, DOMAIN, {})
await hass.async_block_till_done()
yield
@pytest.fixture(autouse=True)
@@ -277,12 +277,13 @@ async def test_init_error(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
caplog: pytest.LogCaptureFixture,
side_effect,
error,
side_effect: APIConnectionError | BadRequestError,
error: str,
) -> None:
"""Test initialization errors."""
with patch(
"openai.resources.models.AsyncModels.list",
new_callable=AsyncMock,
side_effect=side_effect,
):
assert await async_setup_component(hass, DOMAIN, {})
@@ -298,6 +299,7 @@ async def test_init_auth_error(
"""Test auth error during init errors."""
with patch(
"openai.resources.models.AsyncModels.list",
new_callable=AsyncMock,
side_effect=AuthenticationError(
response=httpx.Response(
status_code=500, request=httpx.Request(method="GET", url="test")