AudioMuse-AI icon indicating copy to clipboard operation
AudioMuse-AI copied to clipboard

[BUG] Instant playlist Ollama inference error

Open ElectricTea opened this issue 11 months ago • 2 comments

Describe the bug

Hi, I am running into an error using ollama with audiomuse, and i'm not sure whether the error is on the ollama or audiomuse side of the interaction.

I am using an underpowered ollama instance with limited CPU. This results in long inference times.

In the audiomuse web interface for the Instant playlist, i get the following error in the AI response request summary after waiting two minutes:

❌ AI tool calling failed: Ollama error: The read operation timed out

Error in the audiomuse-ai-flask container

[ERROR]-[<DATE> <TIME>]-Error calling Ollama with tools
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 250, in handle_request
    resp = self._pool.handle_request(req)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection_pool.py", line 256, in handle_request
    raise exc from None
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection_pool.py", line 236, in handle_request
    response = connection.handle_request(
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection.py", line 103, in handle_request
    return self._connection.handle_request(request)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/http11.py", line 136, in handle_request
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/http11.py", line 106, in handle_request
    ) = self._receive_response_headers(**kwargs)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/http11.py", line 177, in _receive_response_headers
    event = self._receive_event(timeout=timeout)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/http11.py", line 217, in _receive_event
    data = self._network_stream.read(
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_backends/sync.py", line 126, in read
    with map_exceptions(exc_map):
  File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ReadTimeout: The read operation timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/ai_mcp_client.py", line 480, in _call_ollama_with_tools
    response = client.post(ollama_url, json=payload)
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 1144, in post
    return self.request(
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 825, in request
    return self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 914, in send
    response = self._send_handling_auth(
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 942, in _send_handling_auth
    response = self._send_handling_redirects(
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 979, in _send_handling_redirects
    response = self._send_single_request(request)
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 1014, in _send_single_request
    response = transport.handle_request(request)
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 249, in handle_request
    with map_httpcore_exceptions():
  File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 118, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ReadTimeout: The read operation timed out

Error in the ollama container:

[GIN] <DATE> - <TIME> | 500 |          2m0s |    <IP ADDRESS> | POST     "/api/generate"

To Reproduce

Steps to reproduce the behavior:

  1. Connect audiomuse to a CPU-only ollama instance with limited CPU (not limited memory)
  2. Select any model big enough that it takes longer than 2 minutes to generate a response
  3. Click "Get playlist Idea" on the instant playlist webpage
  4. Wait two minutes
  5. Open AI Response request summary to see error

Expected behavior

Normal functioning of the instant playlist feature

Screenshots

Image

Environment (please complete the following information):

  • OS: Fedora
  • Deployment: Podman
  • AudioMuse-AI Version: v0.8.2
  • Jellyfin Version: 10.11.5
  • Browser: chrome
  • CPU: QEMU x86-64-v2-AES
  • RAM: 12GB system memory
  • Disk: SSD NVMe

Additional Context

  • Smaller models able to respond within 2 minutes do not result in an error.
  • Cluster playlist naming using the same the large models takes less than 2 minutes per response and works without error.

ElectricTea avatar Dec 18 '25 22:12 ElectricTea

Hi and thanks from the feedback. What you see is an intendend way of working: if the call takes to much times it went in timeout to avoid a never ending wait. This instant playlist functionaltiy do several call to arrive to generating a playlist, so if your model is not able to respond in less than 2 minutes, you run the risk to sit and wait there for half an hours.

Anyway I added the env variable AI_REQUEST_TIMEOUT_SECONDS with default 300 seconds (5 minutes), the fix should be ready in devel in around 30 minutes. Have a try but I still feel that will not be usable if a request takes more than 2 minutes.

NeptuneHub avatar Dec 22 '25 13:12 NeptuneHub

I think this could be closed because there isn’t any additional action on it.

NeptuneHub avatar Jan 06 '26 20:01 NeptuneHub