Skip to content

Commit 2b61601

Browse files
authored
Remove the host from the AI Task generated image URL (home-assistant#151887)
1 parent ee506e6 commit 2b61601

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

homeassistant/components/ai_task/task.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from homeassistant.helpers import llm
2020
from homeassistant.helpers.chat_session import ChatSession, async_get_chat_session
2121
from homeassistant.helpers.event import async_call_later
22-
from homeassistant.helpers.network import get_url
2322
from homeassistant.util import RE_SANITIZE_FILENAME, slugify
2423

2524
from .const import (
@@ -249,7 +248,7 @@ def _purge_image(filename: str, now: datetime) -> None:
249248
if IMAGE_EXPIRY_TIME > 0:
250249
async_call_later(hass, IMAGE_EXPIRY_TIME, partial(_purge_image, filename))
251250

252-
service_result["url"] = get_url(hass) + async_sign_path(
251+
service_result["url"] = async_sign_path(
253252
hass,
254253
f"/api/{DOMAIN}/images/{filename}",
255254
timedelta(seconds=IMAGE_EXPIRY_TIME or 1800),

tests/components/ai_task/test_task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ async def test_generate_image(
286286
assert "image_data" not in result
287287
assert result["media_source_id"].startswith("media-source://ai_task/images/")
288288
assert result["media_source_id"].endswith("_test_task.png")
289-
assert result["url"].startswith("http://10.10.10.10:8123/api/ai_task/images/")
289+
assert result["url"].startswith("/api/ai_task/images/")
290290
assert result["url"].count("_test_task.png?authSig=") == 1
291291
assert result["mime_type"] == "image/png"
292292
assert result["model"] == "mock_model"

0 commit comments

Comments
 (0)