Remove deprecated DALL-E image formats (#122388)
parent
489457c47b
commit
ee30510b23
|
@ -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")),
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue