acon96 / home-llm

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

Ollama: Unexpected error during intent recognition #211

Open Teagan42 opened 2 months ago

Teagan42 commented 2 months ago

Home-Assistant: 2024.8.1 llama-conversation: 0.3.6 webcolors: 1.13

Exact same issue was marked as fixed in 0.3.3 but appears not to be: https://github.com/acon96/home-llm/issues/165 What is odd is that I looked at the webcolors package inside of home-assistant and the constant definitely exists and is exported.

"""
Utility functions for working with the color names and color value
formats defined by the HTML and CSS specifications for use in
documents on the web.

See documentation (in docs/ directory of source distribution) for
details of the supported formats, conventions and conversions.

"""
from .constants import (
    CSS2,
    CSS2_HEX_TO_NAMES,
    CSS2_NAMES_TO_HEX,
    CSS3,
    CSS3_HEX_TO_NAMES,
    CSS3_NAMES_TO_HEX,
    CSS21,
    CSS21_HEX_TO_NAMES,
    CSS21_NAMES_TO_HEX,
    HTML4,
    HTML4_HEX_TO_NAMES,
    HTML4_NAMES_TO_HEX,
)
from .conversion import (
    hex_to_name,
    hex_to_rgb,
    hex_to_rgb_percent,
    name_to_hex,
    name_to_rgb,
    name_to_rgb_percent,
    rgb_percent_to_hex,
    rgb_percent_to_name,
    rgb_percent_to_rgb,
    rgb_to_hex,
    rgb_to_name,
    rgb_to_rgb_percent,
)
from .html5 import (
    html5_parse_legacy_color,
    html5_parse_simple_color,
    html5_serialize_simple_color,
)
from .normalization import (
    normalize_hex,
    normalize_integer_triplet,
    normalize_percent_triplet,
)
from .types import HTML5SimpleColor, IntegerRGB, IntTuple, PercentRGB, PercentTuple

__version__ = "1.13"

__all__ = [
    "HTML4",
    "CSS2",
    "CSS21",
    "CSS3",
    "HTML4_NAMES_TO_HEX",
    "HTML4_HEX_TO_NAMES",
    "CSS2_NAMES_TO_HEX",
    "CSS2_HEX_TO_NAMES",
    "CSS21_HEX_TO_NAMES",
    "CSS21_NAMES_TO_HEX",
    "CSS3_HEX_TO_NAMES",
    "CSS3_NAMES_TO_HEX",
    "name_to_hex",
    "name_to_rgb",
    "name_to_rgb_percent",
    "hex_to_name",
    "hex_to_rgb",
    "hex_to_rgb_percent",
    "rgb_to_hex",
    "rgb_to_name",
    "rgb_to_rgb_percent",
    "rgb_percent_to_hex",
    "rgb_percent_to_name",
    "rgb_percent_to_rgb",
    "html5_parse_simple_color",
    "html5_parse_legacy_color",
    "html5_serialize_simple_color",
    "normalize_hex",
    "normalize_integer_triplet",
    "normalize_percent_triplet",
    "IntegerRGB",
    "PercentRGB",
    "HTML5SimpleColor",
    "IntTuple",
    "PercentTuple",
]

Describe the bug
When performing a chat completion via the Assist Pipeline, the integration raises an AttributeError.

Expected behavior
The Assist Pipeline should be able to determine the intent.

Logs
If applicable, please upload any error or debug logs output by Home Assistant.

024-08-22 05:40:19.961 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 1015, 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 "/usr/src/homeassistant/homeassistant/components/conversation/entity.py", line 47, in internal_async_process
    return await self.async_process(user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/llama_conversation/conversation.py", line 365, in async_process
    message = self._generate_system_prompt(raw_prompt, llm_api)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/llama_conversation/conversation.py", line 776, in _generate_system_prompt
    exposed_attributes = expose_attributes(attributes)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/llama_conversation/conversation.py", line 759, 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'
cryptobench commented 2 months ago

Same issue here

acon96 commented 2 months ago

Can you check home assistant log for errors related to conflicting dependencies? My best guess is that another integration you are using requires the most recent versions of webcolors which do not expose those dictionaries anymore.

pixselious commented 2 months ago

Same issue here HASS 2024.8.2 home-llm 0.3.6

LLM Model 'fixt/home-3b-v3:q4_k_m' (remote)

Temporarily fixed by removing additional attribute "rgb_color" (which exists by default).

IneffableEllie commented 1 month ago

Same issue, here is the traceback:

Logger: homeassistant.components.assist_pipeline.pipeline
Source: components/assist_pipeline/pipeline.py:1015
integration: Assist pipeline ([documentation](https://www.home-assistant.io/integrations/assist_pipeline), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+assist_pipeline%22))
First occurred: 16:52:27 (6 occurrences)
Last logged: 17:01:00

Unexpected error during intent recognition
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/assist_pipeline/pipeline.py", line 1015, 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 "/usr/src/homeassistant/homeassistant/components/conversation/entity.py", line 47, in internal_async_process
    return await self.async_process(user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/llama_conversation/conversation.py", line 365, in async_process
    message = self._generate_system_prompt(raw_prompt, llm_api)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/llama_conversation/conversation.py", line 776, in _generate_system_prompt
    exposed_attributes = expose_attributes(attributes)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/llama_conversation/conversation.py", line 759, 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'