acon96 / home-llm

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

Max retries exceeded with url: /api/generate #79

Closed en-ver closed 4 months ago

en-ver commented 4 months ago

Describe the bug I am getting an error while trying to ask something in the assist chat.

Sorry, there was a problem talking to the backend: HTTPConnectionPool(host='192.168.11.57', port=11434): Max retries exceeded with url: /api/generate (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x8ab31990>: Failed to establish a new connection: [Errno 111] Connection refused'))

Expected behavior The assistant is chatting with me

Logs

Logger: custom_components.llama_conversation Source: custom_components/llama_conversation/init.py:296 Integration: LLaMA Conversation (documentation) First occurred: 21:21:38 (5 occurrences) Last logged: 21:27:55

There was a problem talking to the backend Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 174, in _new_conn conn = connection.create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/urllib3/util/connection.py", line 95, in create_connection raise err File "/usr/local/lib/python3.12/site-packages/urllib3/util/connection.py", line 85, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 715, in urlopen httplib_response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 416, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 244, in request super(HTTPConnection, self).request(method, url, body=body, headers=headers) File "/usr/local/lib/python3.12/http/client.py", line 1327, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/lib/python3.12/http/client.py", line 1373, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.12/http/client.py", line 1322, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.12/http/client.py", line 1081, in _send_output self.send(msg) File "/usr/local/lib/python3.12/http/client.py", line 1025, in send self.connect() File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 205, in connect conn = self._new_conn() ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 186, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x8a252cd8>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 486, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 799, in urlopen retries = retries.increment( ^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/urllib3/util/retry.py", line 592, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.11.57', port=11434): Max retries exceeded with url: /api/generate (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x8a252cd8>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/config/custom_components/llama_conversation/init.py", line 296, in async_process response = await self._async_generate(conversation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/llama_conversation/init.py", line 231, in _async_generate return await self.hass.async_add_executor_job( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/llama_conversation/init.py", line 808, in _generate result = requests.post( ^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/requests/api.py", line 115, in post return request("post", url, data=data, json=json, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/requests/api.py", line 59, in request return session.request(method=method, url=url, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 519, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.11.57', port=11434): Max retries exceeded with url: /api/generate (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x8a252cd8>: Failed to establish a new connection: [Errno 111] Connection refused'))

en-ver commented 4 months ago

ok, it's not an extension issue the root cause is that the ollama api is not exposed to any interfaces other than 127.0.0.1 by default it's just a matter of exposing it to 0.0.0.0 https://github.com/ollama/ollama/blob/main/docs/faq.md#setting-environment-variables-on-mac