mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 16:17:20 +00:00
Remove AITaskEntityFeature.GENERATE_STRUCTURED_DATA feature flag
The structured data generation functionality is now available to all entities that support GENERATE_DATA. This simplifies the API by removing an unnecessary feature flag while maintaining all functionality. - Remove GENERATE_STRUCTURED_DATA from AITaskEntityFeature enum - Remove feature check in task.py - Update services.yaml to remove filter - Update tests to reflect the change 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
e42038742a
commit
9bd7ea78f0
@ -34,6 +34,3 @@ class AITaskEntityFeature(IntFlag):
|
||||
|
||||
GENERATE_DATA = 1
|
||||
"""Generate data based on instructions."""
|
||||
|
||||
GENERATE_STRUCTURED_DATA = 2
|
||||
"""Generate structured data based on instructions."""
|
||||
|
@ -23,6 +23,3 @@ generate_data:
|
||||
example: '{ "name": { "selector": { "text": }, "description": "Name of the user", "required": "True" } } }, "age": { "selector": { "number": }, "description": "Age of the user" } }'
|
||||
selector:
|
||||
object:
|
||||
filter:
|
||||
supported_features:
|
||||
- ai_task.AITaskEntityFeature.GENERATE_STRUCTURED_DATA
|
||||
|
@ -37,15 +37,6 @@ async def async_generate_data(
|
||||
f"AI Task entity {entity_id} does not support generating data"
|
||||
)
|
||||
|
||||
if structure is not None:
|
||||
if (
|
||||
AITaskEntityFeature.GENERATE_STRUCTURED_DATA
|
||||
not in entity.supported_features
|
||||
):
|
||||
raise HomeAssistantError(
|
||||
f"AI Task entity {entity_id} does not support generating structured data"
|
||||
)
|
||||
|
||||
return await entity.internal_async_generate_data(
|
||||
GenDataTask(
|
||||
name=task_name,
|
||||
|
@ -35,9 +35,7 @@ class MockAITaskEntity(AITaskEntity):
|
||||
"""Mock AI Task entity for testing."""
|
||||
|
||||
_attr_name = "Test Task Entity"
|
||||
_attr_supported_features = (
|
||||
AITaskEntityFeature.GENERATE_DATA | AITaskEntityFeature.GENERATE_STRUCTURED_DATA
|
||||
)
|
||||
_attr_supported_features = AITaskEntityFeature.GENERATE_DATA
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Initialize the mock entity."""
|
||||
|
@ -3,14 +3,13 @@
|
||||
from freezegun import freeze_time
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.ai_task import AITaskEntityFeature, async_generate_data
|
||||
from homeassistant.components.conversation import async_get_chat_log
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import chat_session, selector
|
||||
from homeassistant.helpers import chat_session
|
||||
|
||||
from .conftest import TEST_ENTITY_ID, MockAITaskEntity
|
||||
|
||||
@ -128,24 +127,3 @@ async def test_run_data_task_updates_chat_log(
|
||||
async_get_chat_log(hass, session) as chat_log,
|
||||
):
|
||||
assert chat_log.content == snapshot
|
||||
|
||||
|
||||
async def test_run_task_structure_unsupported_feature(
|
||||
hass: HomeAssistant,
|
||||
init_components: None,
|
||||
mock_ai_task_entity: MockAITaskEntity,
|
||||
) -> None:
|
||||
"""Test running a task with an unknown entity."""
|
||||
|
||||
mock_ai_task_entity.supported_features = AITaskEntityFeature.GENERATE_DATA
|
||||
with pytest.raises(
|
||||
HomeAssistantError,
|
||||
match="AI Task entity ai_task.test_task_entity does not support generating structured data",
|
||||
):
|
||||
await async_generate_data(
|
||||
hass,
|
||||
task_name="Test Task",
|
||||
instructions="Test prompt",
|
||||
entity_id=TEST_ENTITY_ID,
|
||||
structure=vol.Schema({vol.Required("name"): selector.TextSelector()}),
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user