mirror of
https://github.com/acon96/home-llm.git
synced 2026-01-08 21:28:05 -05:00
better error handling
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user