diff --git a/custom_components/llama_conversation/__init__.py b/custom_components/llama_conversation/__init__.py index c033a8d..596c530 100644 --- a/custom_components/llama_conversation/__init__.py +++ b/custom_components/llama_conversation/__init__.py @@ -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: diff --git a/custom_components/llama_conversation/agent.py b/custom_components/llama_conversation/agent.py index 3d80235..935c42c 100644 --- a/custom_components/llama_conversation/agent.py +++ b/custom_components/llama_conversation/agent.py @@ -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)