From ee30510b2303f75ee36855c419bea24e15f8d739 Mon Sep 17 00:00:00 2001 From: Denis Shulyaka Date: Mon, 22 Jul 2024 22:57:48 +0300 Subject: [PATCH] Remove deprecated DALL-E image formats (#122388) --- .../openai_conversation/__init__.py | 33 ++----------------- .../openai_conversation/test_init.py | 27 --------------- 2 files changed, 3 insertions(+), 57 deletions(-) diff --git a/homeassistant/components/openai_conversation/__init__.py b/homeassistant/components/openai_conversation/__init__.py index 0ba7b53795b..75b5db23094 100644 --- a/homeassistant/components/openai_conversation/__init__.py +++ b/homeassistant/components/openai_conversation/__init__.py @@ -2,8 +2,6 @@ from __future__ import annotations -from typing import Literal, cast - import openai import voluptuous as vol @@ -20,11 +18,7 @@ from homeassistant.exceptions import ( HomeAssistantError, ServiceValidationError, ) -from homeassistant.helpers import ( - config_validation as cv, - issue_registry as ir, - selector, -) +from homeassistant.helpers import config_validation as cv, selector from homeassistant.helpers.typing import ConfigType from .const import DOMAIN, LOGGER @@ -53,32 +47,11 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: client: openai.AsyncClient = entry.runtime_data - if call.data["size"] in ("256", "512", "1024"): - ir.async_create_issue( - hass, - DOMAIN, - "image_size_deprecated_format", - breaks_in_ha_version="2024.7.0", - is_fixable=False, - is_persistent=True, - learn_more_url="https://www.home-assistant.io/integrations/openai_conversation/", - severity=ir.IssueSeverity.WARNING, - translation_key="image_size_deprecated_format", - ) - size = "1024x1024" - else: - size = call.data["size"] - - size = cast( - Literal["256x256", "512x512", "1024x1024", "1792x1024", "1024x1792"], - size, - ) # size is selector, so no need to check further - try: response = await client.images.generate( model="dall-e-3", prompt=call.data["prompt"], - size=size, + size=call.data["size"], quality=call.data["quality"], style=call.data["style"], response_format="url", @@ -102,7 +75,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: ), vol.Required("prompt"): cv.string, vol.Optional("size", default="1024x1024"): vol.In( - ("1024x1024", "1024x1792", "1792x1024", "256", "512", "1024") + ("1024x1024", "1024x1792", "1792x1024") ), vol.Optional("quality", default="standard"): vol.In(("standard", "hd")), vol.Optional("style", default="vivid"): vol.In(("vivid", "natural")), diff --git a/tests/components/openai_conversation/test_init.py b/tests/components/openai_conversation/test_init.py index c9431aa1083..d78ce398c92 100644 --- a/tests/components/openai_conversation/test_init.py +++ b/tests/components/openai_conversation/test_init.py @@ -60,33 +60,6 @@ from tests.common import MockConfigEntry "style": "natural", }, ), - ( - {"prompt": "Picture of a dog", "size": "256"}, - { - "prompt": "Picture of a dog", - "size": "1024x1024", - "quality": "standard", - "style": "vivid", - }, - ), - ( - {"prompt": "Picture of a dog", "size": "512"}, - { - "prompt": "Picture of a dog", - "size": "1024x1024", - "quality": "standard", - "style": "vivid", - }, - ), - ( - {"prompt": "Picture of a dog", "size": "1024"}, - { - "prompt": "Picture of a dog", - "size": "1024x1024", - "quality": "standard", - "style": "vivid", - }, - ), ], ) async def test_generate_image_service(