Performance improvements for Assist (#86966)
* Move hassil recognize into executor * Bump hassil to 0.2.6 * Disable template parsing in name/area lists * Don't iterate over hass.config.components directlypull/86794/head
parent
e57dad79fc
commit
f7fdaadde0
|
@ -127,7 +127,9 @@ class DefaultAgent(AbstractConversationAgent):
|
|||
"name": self._make_names_list(),
|
||||
}
|
||||
|
||||
result = recognize(user_input.text, lang_intents.intents, slot_lists=slot_lists)
|
||||
result = await self.hass.async_add_executor_job(
|
||||
recognize, user_input.text, lang_intents.intents, slot_lists
|
||||
)
|
||||
if result is None:
|
||||
_LOGGER.debug("No intent was matched for '%s'", user_input.text)
|
||||
return _make_error_result(
|
||||
|
@ -216,13 +218,15 @@ class DefaultAgent(AbstractConversationAgent):
|
|||
|
||||
async def async_get_or_load_intents(self, language: str) -> LanguageIntents | None:
|
||||
"""Load all intents of a language with lock."""
|
||||
hass_components = set(self.hass.config.components)
|
||||
async with self._lang_lock[language]:
|
||||
return await self.hass.async_add_executor_job(
|
||||
self._get_or_load_intents,
|
||||
language,
|
||||
self._get_or_load_intents, language, hass_components
|
||||
)
|
||||
|
||||
def _get_or_load_intents(self, language: str) -> LanguageIntents | None:
|
||||
def _get_or_load_intents(
|
||||
self, language: str, hass_components: set[str]
|
||||
) -> LanguageIntents | None:
|
||||
"""Load all intents for language (run inside executor)."""
|
||||
lang_intents = self._lang_intents.get(language)
|
||||
|
||||
|
@ -235,7 +239,7 @@ class DefaultAgent(AbstractConversationAgent):
|
|||
|
||||
# Check if any new components have been loaded
|
||||
intents_changed = False
|
||||
for component in self.hass.config.components:
|
||||
for component in hass_components:
|
||||
if component in loaded_components:
|
||||
continue
|
||||
|
||||
|
@ -361,7 +365,7 @@ class DefaultAgent(AbstractConversationAgent):
|
|||
for alias in entry.aliases:
|
||||
areas.append((alias, entry.id))
|
||||
|
||||
self._areas_list = TextSlotList.from_tuples(areas)
|
||||
self._areas_list = TextSlotList.from_tuples(areas, allow_template=False)
|
||||
return self._areas_list
|
||||
|
||||
def _make_names_list(self) -> TextSlotList:
|
||||
|
@ -387,7 +391,7 @@ class DefaultAgent(AbstractConversationAgent):
|
|||
# Default name
|
||||
names.append((state.name, state.entity_id, context))
|
||||
|
||||
self._names_list = TextSlotList.from_tuples(names)
|
||||
self._names_list = TextSlotList.from_tuples(names, allow_template=False)
|
||||
return self._names_list
|
||||
|
||||
def _get_error_text(
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"domain": "conversation",
|
||||
"name": "Conversation",
|
||||
"documentation": "https://www.home-assistant.io/integrations/conversation",
|
||||
"requirements": ["hassil==0.2.5", "home-assistant-intents==2023.1.25"],
|
||||
"requirements": ["hassil==0.2.6", "home-assistant-intents==2023.1.25"],
|
||||
"dependencies": ["http"],
|
||||
"codeowners": ["@home-assistant/core"],
|
||||
"quality_scale": "internal",
|
||||
|
|
|
@ -21,7 +21,7 @@ cryptography==39.0.0
|
|||
dbus-fast==1.84.0
|
||||
fnvhash==0.1.0
|
||||
hass-nabucasa==0.61.0
|
||||
hassil==0.2.5
|
||||
hassil==0.2.6
|
||||
home-assistant-bluetooth==1.9.2
|
||||
home-assistant-frontend==20230128.0
|
||||
home-assistant-intents==2023.1.25
|
||||
|
|
|
@ -874,7 +874,7 @@ hass-nabucasa==0.61.0
|
|||
hass_splunk==0.1.1
|
||||
|
||||
# homeassistant.components.conversation
|
||||
hassil==0.2.5
|
||||
hassil==0.2.6
|
||||
|
||||
# homeassistant.components.tasmota
|
||||
hatasmota==0.6.3
|
||||
|
|
|
@ -666,7 +666,7 @@ habitipy==0.2.0
|
|||
hass-nabucasa==0.61.0
|
||||
|
||||
# homeassistant.components.conversation
|
||||
hassil==0.2.5
|
||||
hassil==0.2.6
|
||||
|
||||
# homeassistant.components.tasmota
|
||||
hatasmota==0.6.3
|
||||
|
|
Loading…
Reference in New Issue