Allow unregistering LLM APIs (#135162)

This commit is contained in:
Allen Porter
2025-01-09 08:18:25 -08:00
committed by GitHub
parent ec37e1ff8d
commit 6e111d18ec
2 changed files with 69 additions and 6 deletions

View File

@@ -85,7 +85,7 @@ def _async_get_apis(hass: HomeAssistant) -> dict[str, API]:
@callback
def async_register_api(hass: HomeAssistant, api: API) -> None:
def async_register_api(hass: HomeAssistant, api: API) -> Callable[[], None]:
"""Register an API to be exposed to LLMs."""
apis = _async_get_apis(hass)
@@ -94,6 +94,13 @@ def async_register_api(hass: HomeAssistant, api: API) -> None:
apis[api.id] = api
@callback
def unregister() -> None:
"""Unregister the API."""
apis.pop(api.id)
return unregister
async def async_get_api(
hass: HomeAssistant, api_id: str, llm_context: LLMContext