mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 09:23:17 -04:00
Set tool metadata in humidifier (#182703)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
7c55612d05
commit
00b2c65f2a
@@ -4,13 +4,27 @@ from homeassistant.components.homeassistant import async_should_expose
|
||||
from homeassistant.components.llm import LLMTools
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import intent
|
||||
from homeassistant.helpers.llm import LLM_API_ASSIST, IntentTool, LLMContext, Tool
|
||||
from homeassistant.helpers.llm import (
|
||||
LLM_API_ASSIST,
|
||||
IntentTool,
|
||||
LLMContext,
|
||||
Tool,
|
||||
ToolAnnotations,
|
||||
)
|
||||
|
||||
from .const import DOMAIN
|
||||
from .intent import INTENT_HUMIDITY, INTENT_MODE
|
||||
|
||||
# Intents owned by this integration that are exposed as LLM tools.
|
||||
LLM_INTENTS = (INTENT_MODE, INTENT_HUMIDITY)
|
||||
# Each intent sets a value on the user's own entities, so calling one again
|
||||
# with the same arguments has no further effect.
|
||||
LLM_ANNOTATIONS = ToolAnnotations(idempotent=True, open_world=False)
|
||||
|
||||
# Intents owned by this integration that are exposed as LLM tools, with the
|
||||
# title shown for each.
|
||||
LLM_INTENTS = {
|
||||
INTENT_MODE: "Set humidifier mode",
|
||||
INTENT_HUMIDITY: "Set humidity",
|
||||
}
|
||||
|
||||
|
||||
@callback
|
||||
@@ -28,7 +42,13 @@ def async_get_tools(
|
||||
return None
|
||||
|
||||
tools: list[Tool] = [
|
||||
IntentTool(f"{DOMAIN}__{handler.intent_type}", handler)
|
||||
IntentTool(
|
||||
f"{DOMAIN}__{handler.intent_type}",
|
||||
handler,
|
||||
title=LLM_INTENTS[handler.intent_type],
|
||||
integration=DOMAIN,
|
||||
annotations=LLM_ANNOTATIONS,
|
||||
)
|
||||
for handler in intent.async_get(hass)
|
||||
if handler.intent_type in LLM_INTENTS
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user