acon96 / home-llm

A Home Assistant integration & Model to control your smart home using a Local LLM
483 stars 56 forks source link

Unexpected error during intent recognition (not enough values to unpack) #171

Open caphector opened 2 weeks ago

caphector commented 2 weeks ago

Describe the bug
When I tell any of the LLM models to change device state ("turn on office light" for example) it returns Unexpected error during intent recognition

Expected behavior
Device state is changed

Logs

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/assist_pipeline/pipeline.py", line 994, in recognize_intent
    conversation_result = await conversation.async_converse(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/conversation/agent_manager.py", line 108, in async_converse
    result = await method(conversation_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/llama_conversation/agent.py", line 396, in async_process
    tool_response = await llm_api.async_call_tool(tool_input)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/llm.py", line 158, in async_call_tool
    return await tool.async_call(self.api.hass, tool_input, self.llm_context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/llama_conversation/__init__.py", line 145, in async_call
    domain, service = tuple(tool_input.tool_args["service"].split("."))
    ^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)
caphector commented 2 weeks ago

Here are some more logs:

2024-06-16 23:18:33.795 DEBUG (MainThread) [custom_components.llama_conversation.agent] I'm unable to physically turn on lights, but the hall light should turn on now that I've been instructed to do so.

{"service": "light", "target_device": "light.hall_light", "state": "on"}
christoros commented 2 weeks ago

I also have this error. Using version 0.3.3 and ollama api.

Unexpected error during intent recognition

Logs:

2024-06-18 11:17:56.054 ERROR (MainThread) [homeassistant.components.assist_pipeline.pipeline] Unexpected error during intent recognition
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/assist_pipeline/pipeline.py", line 994, in recognize_intent
    conversation_result = await conversation.async_converse(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/conversation/agent_manager.py", line 108, in async_converse
    result = await method(conversation_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/llama_conversation/agent.py", line 284, in async_process
    message = self._generate_system_prompt(raw_prompt, llm_api)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/llama_conversation/agent.py", line 694, in _generate_system_prompt
    exposed_attributes = expose_attributes(attributes)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/llama_conversation/agent.py", line 677, in expose_attributes
    value = F"{closest_color(value)} {value}"
               ^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/llama_conversation/utils.py", line 31, in closest_color
    for key, name in webcolors.CSS3_HEX_TO_NAMES.items():
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'webcolors' has no attribute 'CSS3_HEX_TO_NAMES'

Removing the rgb_color attribute fixes the error.

acon96 commented 2 weeks ago

Here are some more logs:

2024-06-16 23:18:33.795 DEBUG (MainThread) [custom_components.llama_conversation.agent] I'm unable to physically turn on lights, but the hall light should turn on now that I've been instructed to do so.

{"service": "light", "target_device": "light.hall_light", "state": "on"}

The model output shown here isn't quite in the correct format. It should be:

{"service": "light.turn_on", "target_device": "light.hall_light"}

I can make the error handling better so that the error message isn't so confusing.