HAOS : Installer ses propres extensions python (llama-cpp-python)?

Bonjour à tous,

Je suis en train de jouer avec les assistants vocaux locaux, et pour rendre ce dernier moins stupide, j’aimerai bien lui intégrer un llm local.

Au cours de mes recherches, je suis donc tombé là dessus :

dont la doc dit clairement :

Make sure you have llama-cpp-python>=0.2.29 in order to run these models.

Direction donc llama-cpp-python : GitHub - abetlen/llama-cpp-python: Python bindings for llama.cpp qui me dit :

llama-cpp-python can be installed directly from PyPI as a source distribution by running:

pip install llama-cpp-python

Bon, j’en suis là, je n’aurais plus qu’à taper la commande dans mon ssh, mais les questions sont :

  • est-ce recommandé
  • y’a pas plus intelligent
  • vous auriez des conseils / recos ? (à part faire un backup avant)
  • j’ai loupé un truc ?

Merci d’avance à tous :slight_smile:

Ma configuration


System Information

version core-2024.2.1
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.1
os_name Linux
os_version 6.1.74-haos
arch x86_64
timezone Europe/Paris
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 4886
Installed Version 1.34.0
Stage running
Available Repositories 1391
Downloaded Repositories 15
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 11.5
update_channel stable
supervisor_version supervisor-2024.01.1
agent_version 1.6.0
docker_version 24.0.7
disk_total 30.8 GB
disk_used 24.3 GB
healthy true
supported true
board ova
supervisor_api ok
version_api ok
installed_addons Terminal & SSH (9.9.0), Studio Code Server (5.15.0), Node-RED (17.0.7), Home Assistant Google Drive Backup (0.112.1), File editor (5.8.0), Whatsapp (1.3.5), Log Viewer (0.17.0), AppDaemon (0.16.4), Bookstack (2.0.1), MariaDB (2.6.1), openWakeWord (1.8.2), snowboy (1.1.0), vosk (1.5.1), porcupine1 (1.1.0), Piper (1.4.0)
Dashboards
dashboards 2
resources 9
views 9
mode storage
Recorder
oldest_recorder_run 4 février 2024 à 10:17
current_recorder_run 14 février 2024 à 15:26
estimated_db_size 181.13 MiB
database_engine sqlite
database_version 3.44.2
___

Hello @titoumimi

Il me semble que si tu crées un custom_component et indique les packages que tu veux, HA devrait les installer:

Merci beaucoup de ton retour, je ne connais pas du tout ce pan de home assistant :slight_smile:

J’ai donc tenté de rajouter llama-cpp-python dans le manifest de l’extension concernée, redémarré HA, et essayer de lancer l’intégration, mais là je me fais insulter sauvagement par les logs, et ça dépasse clairement mes compétences :wink:

Méchants logs pas beaux

`× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
2024-02-14 16:37:12.621 ERROR (SyncWorker_3) [homeassistant.util.package] Unable to install package llama-cpp-python: error: subprocess-exited-with-error

× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [40 lines of output]
Traceback (most recent call last):
File « /usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py », line 353, in
main()
File « /usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py », line 335, in main
json_out[‹ return_val ›] = hook(**hook_input[‹ kwargs ›])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py », line 149, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /tmp/pip-build-env-q0iqqkak/overlay/lib/python3.12/site-packages/scikit_build_core/build/init.py », line 72, in prepare_metadata_for_build_wheel
return _build_wheel_impl(
^^^^^^^^^^^^^^^^^^
File « /tmp/pip-build-env-q0iqqkak/overlay/lib/python3.12/site-packages/scikit_build_core/build/wheel.py », line 151, in _build_wheel_impl
cmake = CMake.default_search(version=settings.cmake.version, env=os.environ)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /tmp/pip-build-env-q0iqqkak/overlay/lib/python3.12/site-packages/scikit_build_core/cmake.py », line 59, in default_search
cmake_program = best_program(candidates, version=version)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /tmp/pip-build-env-q0iqqkak/overlay/lib/python3.12/site-packages/scikit_build_core/program_search.py », line 145, in best_program
for program in programs:
File « /tmp/pip-build-env-q0iqqkak/overlay/lib/python3.12/site-packages/scikit_build_core/program_search.py », line 101, in get_cmake_programs
yield get_cmake_program(cmake_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /tmp/pip-build-env-q0iqqkak/overlay/lib/python3.12/site-packages/scikit_build_core/program_search.py », line 80, in get_cmake_program
result = Run().capture(cmake_path, « –version »)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /tmp/pip-build-env-q0iqqkak/overlay/lib/python3.12/site-packages/scikit_build_core/_shutil.py », line 43, in capture
return self._run(args, capture=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /tmp/pip-build-env-q0iqqkak/overlay/lib/python3.12/site-packages/scikit_build_core/_shutil.py », line 71, in _run
return subprocess.run(
^^^^^^^^^^^^^^^
File « /usr/local/lib/python3.12/subprocess.py », line 548, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /usr/local/lib/python3.12/subprocess.py », line 1026, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File « /usr/local/lib/python3.12/subprocess.py », line 1950, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: ‹ /tmp/pip-build-env-q0iqqkak/normal/lib/python3.12/site-packages/cmake/data/bin/cmake ›
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
2024-02-14 16:37:12.622 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File « /usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py », line 452, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /usr/local/lib/python3.12/site-packages/aiohttp/web_app.py », line 543, in _handle
resp = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File « /usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py », line 114, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/components/http/security_filter.py », line 91, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/components/http/forwarded.py », line 100, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/components/http/request_context.py », line 28, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/components/http/ban.py », line 80, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/components/http/auth.py », line 235, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/components/http/headers.py », line 31, in headers_middleware
response = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/components/http/view.py », line 149, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/components/http/decorators.py », line 72, in with_admin
return await func(self, request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/components/config/config_entries.py », line 153, in post
return await super().post(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/components/http/data_validator.py », line 72, in wrapper
result = await method(view, request, data, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py », line 71, in post
result = await self._flow_mgr.async_init(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/config_entries.py », line 947, in async_init
flow, result = await task
^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/config_entries.py », line 965, in _async_init
flow = await self.async_create_flow(handler, context=context, data=data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/config_entries.py », line 1076, in async_create_flow
handler = await _async_get_flow_handler(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/config_entries.py », line 2294, in _async_get_flow_handler
await _load_integration(hass, domain, hass_config)
File « /usr/src/homeassistant/homeassistant/config_entries.py », line 2270, in _load_integration
await async_process_deps_reqs(hass, hass_config, integration)
File « /usr/src/homeassistant/homeassistant/setup.py », line 467, in async_process_deps_reqs
await requirements.async_get_integration_with_requirements(
File « /usr/src/homeassistant/homeassistant/requirements.py », line 52, in async_get_integration_with_requirements
return await manager.async_get_integration_with_requirements(domain)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File « /usr/src/homeassistant/homeassistant/requirements.py », line 175, in async_get_integration_with_requirements
await self._async_process_integration(integration, done)
File « /usr/src/homeassistant/homeassistant/requirements.py », line 190, in _async_process_integration
await self.async_process_requirements(
File « /usr/src/homeassistant/homeassistant/requirements.py », line 255, in async_process_requirements
await self._async_process_requirements(name, missing)
File « /usr/src/homeassistant/homeassistant/requirements.py », line 293, in _async_process_requirements
raise RequirementsNotFound(name, list(failures))
homeassistant.requirements.RequirementsNotFound: Requirements for llama_conversation not found: [‹ llama-cpp-python ›].`

Je vais rollback du coup, et essayer d’explorer plus loin le GIT initial, des fois que j’aie manqué un truc…

Excuse j’avais pas lu le GitHub que tu donnais :smiley:

Il semble que le package doit être installé sur ton PC pour entrainer et/ou utiliser ton model et avoir un serveur qui tourne sur ton PC. Ensuite le composant va parler à ce serveur:

In order to integrate with Home Assistant, we provide a custom_component
that exposes the locally running LLM as a "conversation agent"

Après je t’avoue que j’ai pas tout compris en lisant rapidement :smiley:

pas de soucis :pray:

Par contre, je pense qu’il faut bien que le module soit installé sur la machine, quand j’essaie de lancer l’intégration sans, je me fait rembarrer :

image

Bon, j’ai sans doute voulu aller trop vite, il y a d’autres choses ensuite dans la doc.

Qui plantent, mais qui font avancer le schmilblik.

Donc pause sur le topic pour l’instant, je me décrasse le neurone et je reviendrai si besoin.

Merci de l’aide !