better error handling

This commit is contained in:
Alex O'Connell
2024-07-29 21:38:25 -04:00
parent 00be01c49f
commit 21ecc293ee
2 changed files with 6 additions and 1 deletions

View File

@@ -145,7 +145,11 @@ class HassServiceTool(llm.Tool):
self, hass: HomeAssistant, tool_input: llm.ToolInput, llm_context: llm.LLMContext
) -> JsonObjectType:
"""Call the tool."""
domain, service = tuple(tool_input.tool_args["service"].split("."))
try:
domain, service = tuple(tool_input.tool_args["service"].split("."))
except ValueError:
return { "result": "unknown service" }
target_device = tool_input.tool_args["target_device"]
if domain not in self.ALLOWED_DOMAINS or service not in self.ALLOWED_SERVICES:

View File

@@ -404,6 +404,7 @@ class LocalLLMAgent(AbstractConversationAgent):
tool_args=parsed_tool_call["arguments"],
)
tool_response = None
try:
tool_response = await llm_api.async_call_tool(tool_input)
_LOGGER.debug("Tool response: %s", tool_response)