Skip to content

Conversation

@moutasem1989
Copy link
Contributor

Since both Docker Model Runner (DMR) and Open AI use the same API endpoints, I wanted to help out adding support to this project. I love self hosting but Ollama has a lot of issues. I think DMR could be a great replacement since it could be already included in the Docker compose. I did not test this yet because My machine is still busy testing other things.

I did changes that could affect other functionalities so please do a thural review to make suer it is going in the right direction

UNTESTED

Since both Docker Model Runner (DMR) and Open AI use the same API endpoints, I wanted to help out adding support to this project. I love self hosting but Ollama has a lot of issues. I think DMR could be a great replacement since it could be already included in the Docker compose.
I did not test this yet because My machine is still busy testing other things.
@NeptuneHub
Copy link
Owner

Thanks for the contribution to AudioMuseAI.

I updated the smoketest that you can find in /test can you run it and shae the result? they should take around 15-20 minute.
In future I would like to implement automated test even more, to have at least a starting point. Unulky is difficult to add directly in the github action because it need an up and running Music Server full of song.

Also can you also add a docker-compose-openai.yaml file to deploy AudioMuse-AI with the AI and a model ready to use? (let's say Mistral:7b ?) So that will be easy to be test and used too.

I renamed the functions and variables to be easier to understand and follow:
One can either use self-hosted AI Server Pen-AI-API compatible (such as Local-AI, Docker Model Runner, vLLM, OpenLLM, etc..)
Or use Open AI Servers by not providing a URL ( in that case a valid API Key is required)
@NeptuneHub
Copy link
Owner

Hi, I don't understand if it's ready or you're still working on it, because this is a PR open and not just a draft.

Anyway I recompiled the image, got your docker-compose.yaml example where I just put the Jellyfin information + the OpenAI API Token, and it give error. I didn't give any url or so because I understood the default url for the cloud API is already there.
I attach below the log.

Starting web service...
[INFO]-[23-10-2025 11-47-08]-Starting AudioMuse-AI Backend version v0.7.2-beta
[INFO]-[23-10-2025 11-47-10]-Attempting to load Voyager index from database into memory...
[WARNING]-[23-10-2025 11-47-10]-Voyager index 'music_library' not found in the database. Cache will be empty.
[INFO]-[23-10-2025 11-47-10]-In-memory map projection loaded at startup.
 * Serving Flask app 'app'
 * Debug mode: off
[INFO]-[23-10-2025 11-47-10]-Background thread started. Listening for Voyager index reloads on Redis channel 'index-updates'.
[INFO]-[23-10-2025 11-47-10]-WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:8000
 * Running on http://172.18.0.4:8000
[INFO]-[23-10-2025 11-47-10]-Press CTRL+C to quit
[INFO]-[23-10-2025 11-48-23]-192.168.3.111 - - [23/Oct/2025 11:48:23] "GET / HTTP/1.1" 200 -
[INFO]-[23-10-2025 11-48-23]-192.168.3.111 - - [23/Oct/2025 11:48:23] "GET /static/style.css HTTP/1.1" 200 -
[INFO]-[23-10-2025 11-48-23]-192.168.3.111 - - [23/Oct/2025 11:48:23] "GET /static/script.js HTTP/1.1" 200 -
[INFO]-[23-10-2025 11-48-23]-192.168.3.111 - - [23/Oct/2025 11:48:23] "GET /static/menu.css HTTP/1.1" 200 -
[INFO]-[23-10-2025 11-48-23]-192.168.3.111 - - [23/Oct/2025 11:48:23] "GET /static/menu.js HTTP/1.1" 200 -
[INFO]-[23-10-2025 11-48-23]-192.168.3.111 - - [23/Oct/2025 11:48:23] "GET /api/config HTTP/1.1" 200 -
[INFO]-[23-10-2025 11-48-23]-192.168.3.111 - - [23/Oct/2025 11:48:23] "GET /api/active_tasks HTTP/1.1" 200 -
[INFO]-[23-10-2025 11-48-23]-192.168.3.111 - - [23/Oct/2025 11:48:23] "GET /favicon.ico HTTP/1.1" 404 -
[INFO]-[23-10-2025 11-48-23]-192.168.3.111 - - [23/Oct/2025 11:48:23] "GET /api/last_task HTTP/1.1" 200 -
[INFO]-[23-10-2025 11-48-26]-192.168.3.111 - - [23/Oct/2025 11:48:26] "GET /api/active_tasks HTTP/1.1" 200 -
[INFO]-[23-10-2025 11-48-27]-192.168.3.111 - - [23/Oct/2025 11:48:27] "GET /chat HTTP/1.1" 308 -
[INFO]-[23-10-2025 11-48-27]-192.168.3.111 - - [23/Oct/2025 11:48:27] "GET /chat/ HTTP/1.1" 200 -
[INFO]-[23-10-2025 11-48-27]-192.168.3.111 - - [23/Oct/2025 11:48:27] "GET /static/style.css HTTP/1.1" 304 -
[INFO]-[23-10-2025 11-48-27]-192.168.3.111 - - [23/Oct/2025 11:48:27] "GET /static/menu.js HTTP/1.1" 304 -
[INFO]-[23-10-2025 11-48-27]-192.168.3.111 - - [23/Oct/2025 11:48:27] "GET /static/menu.css HTTP/1.1" 304 -
[INFO]-[23-10-2025 11-48-27]-192.168.3.111 - - [23/Oct/2025 11:48:27] "GET /chat/api/config_defaults HTTP/1.1" 200 -
[ERROR]-[23-10-2025 11-48-36]-Network error when calling OpenAI-compatible API: 404 Client Error: Not Found for url: https://api.openai.com/v1/chat/completions
Traceback (most recent call last):
  File "/app/ai.py", line 279, in get_openai_playlist_name
    response.raise_for_status()
  File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 1026, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.openai.com/v1/chat/completions

Please let me clearly when do you think this PR is ready to be tested and merged, and share how. I understood that both with a selfhosted model and with on internet API should be possible, so please share example on both.

Also when finished please run the smoke test in /test and share the result.

Thanks!

@moutasem1989
Copy link
Contributor Author

I definitely still need time to make a working PR. I am still testing functionality and I will definitely let you know when it is ready. I solved the API issues but now working on default values and correctly naming functions.

Use Open AI SDK for API calls
Still issues with API key. still debuging
To test this make sure Docker is up to date and that docker-model-plugin is installed.

I added the correct configurations to access LLM Model from inside the container. It is OpenAI API compatible. I used OpenAI SDK Python Library to impliment the function.

The LLM included is about 500mb and on a labtop processor i5 it took around 20s to return a result.
@moutasem1989
Copy link
Contributor Author

moutasem1989 commented Oct 24, 2025

I added a compose yaml for OpenAI integration. To run it, docker must be on the latest version and DMR is installed:

$ sudo apt-get update
$ sudo apt-get install docker-model-plugin

I attached a small LLM (ca. 500mb) to generate playlist names. The values for openai_model_name and openai_base_url are the ones that allow the container to connect to DMR using OpenAI API.
The value openai_api_key is ignored unless it is needed by OpenAI or DMR.

I am currently running a main_clustering task and so far no errors are seen.
I did the pytest and it all "Failed". So I am not sure what information that provides.

I think however I am in it over my head because some things are not yet correct in the UI:

This is correct:
Screenshot 2025-10-24 at 18 02 10

This is incorrect:
Screenshot 2025-10-24 at 20 01 37

In this picture are the applied values to the ENV. but are not correctly shown in the UI.
On an unrelated note, The User ID Text input in Sonic Fingerprint is not available on main:

Screenshot 2025-10-24 at 19 51 13

Can you please help fix the UI issues and check if all functions related to AI Naming are correctly changed?

Updated the placeholder for OpenAI Base URL to reflect the correct endpoint for chat completions.
BaseURL should be empty to use OpenAI API.
Or a URL to v1/chat/completions api endpoint is to be provided. In the openai docker compose yaml i provided the DMR url: "http://172.17.0.1:12434/engines/llama.cpp/v1/chat/completions"
@NeptuneHub
Copy link
Owner

I try to spin up AudioMuse-AI with your code and your docker-compose.yaml example but I have issue:

docker compose up -d
validating /home/guido/docker-compose.yaml: services.audiomuse-ai-flask Additional property models is not allowed

Searching around it seems that this is because model runner is a feature for Docker Desktop. If this is correct is not good because AudioMuse-AI is primary a software for homelab that should work on headless server.

I try to remove the model integrated part, trying to run it with exeternal API, but now in /chat functionality openAI didn't apepar in the provider.

Please review the docker compose file and/or provide a version that could work also without the integrated model. Thanks!

@moutasem1989
Copy link
Contributor Author

To use Docker Model Runner you have to update Docker and install docker-model-plugin. See here. It is not a desktop exclusive feature. When executing "up" command on the compose file, Docker automatically sets up the AI model and links it to the containers. Because of convenience compared to other solutions like Ollama, I wanted to help adding the integration. Furthermore, other self hosted services like LM Studio also use OpenAI API.

Using get_openai_playlist_name function in ai.py I was able to create playlist names using DMR. For it to work, it needs those variables: OPENAI_MODEL_NAME, OPENAI_API_KEY, OPENAI_BASE_URL, OPENAI_API_TOKENS.
I just duplicated the approach Ollama was implemented in but it seems that it is simply not working correctly. If you could help finishing the implementation it would be amazing.

still trying to figure out how AI Clients were implimented
I replicate exact implimentation of Gemini and Ollama hoping that solves the issues. It is not clear how API keys are sent from UI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants