Skip to content

Configurable LLM model/provider + multi-library support (supersedes #2, #3, #4)#5

Merged
LubergAlexander merged 1 commit into
masterfrom
feat/configurable-llm-and-multi-library
Jul 21, 2026
Merged

Configurable LLM model/provider + multi-library support (supersedes #2, #3, #4)#5
LubergAlexander merged 1 commit into
masterfrom
feat/configurable-llm-and-multi-library

Conversation

@LubergAlexander

Copy link
Copy Markdown
Owner

Summary

Consolidates and reimplements the good ideas from the three open PRs into one cohesive change, and adds the runtime-configurable model/provider/API key that ties them together. The originals overlapped heavily (#3 contained all of #2) and had quality issues, so this reimplements them cleanly with credit to the original authors.

Closes #2, #3, #4 (superseded).

What's included

🎵 Multiple music libraries — supersedes #2 (@othyn)

  • Discovers every artist-type library section instead of assuming one named "Music".
  • Caches artists across all libraries (de-duplicated by rating key) and searches across all of them.

🤖 Model selection + playlist metadata — supersedes #3 (@othyn)

  • Playlist summary records provenance: Generated by Plexmuse + prompt + model.
  • Bug fix: min_tracks/max_tracks were never interpolated into the track-recommendation system prompt (missing f-string) — now they are.
  • UI model selector is driven by server config, not hardcoded gpt-4/gpt-3.5-turbo.

🔑 Robust API key handling — supersedes #4 (@quinneydavid)

  • Validates the required provider key before every call. Critically, empty/whitespace *_API_KEY values are treated as missinglitellm.validate_environment alone reports an empty OPENAI_API_KEY= as present, which is the exact bug Fix handling of empty OpenAI API key #4 was chasing.
  • Fails fast with a clear, actionable error naming the env var to set — no silent, hardcoded fallback to a (now-deprecated) Claude model.
  • Centralized in a single _complete() helper, eliminating the duplicated completion() calls from the original PR.

⚙️ Configurable at Docker launch (new)

  • PLEXMUSE_MODEL — default model; any LiteLLM string, so any provider (OpenAI, Anthropic, Gemini, …).
  • PLEXMUSE_MODELS — optional comma-separated list offered in the UI dropdown.
  • New GET /config endpoint + injected window config expose these to the frontend.
  • Documented in README.md and .env.example.
docker run -p 8000:8000 \
  -e PLEX_BASE_URL=... -e PLEX_TOKEN=... \
  -e PLEXMUSE_MODEL=anthropic/claude-3-5-sonnet-latest \
  -e ANTHROPIC_API_KEY=sk-ant-... \
  ghcr.io/lubergalexander/plexmuse:latest

Notes / deviations from the originals

  • Did not adopt the originals' CI/CD (ci-cd.yml) edits — they conflict with the current master latest-tagging approach.
  • Did not adopt PR LLM selection (depends on #2) #3's wholesale Prettier reformat of app.js/index.html; kept changes minimal and in the existing style.

Testing

  • Test suite: 21 → 32 passing, including new coverage for empty/missing API keys, multi-library init & de-dup, playlist metadata, config parsing, and /config.
  • pylint 10.00/10; flake8, black --check, isort --check all clean.

🤖 Generated with Claude Code

Consolidates and reimplements the good ideas from PRs #2, #3, and #4 into
a single cohesive change, plus adds runtime-configurable model/provider/key.

Multiple music libraries (supersedes #2, by @othyn):
- Discover every "artist"-type library section instead of assuming one
  named "Music"; cache artists across all of them (de-duplicated).
- Search across all libraries for artists and tracks.

LLM selection + metadata (supersedes #3, by @othyn):
- Playlist summary now records provenance (prompt + model).
- Fix min/max track bounds never being interpolated into the system prompt.
- UI model selector is driven by server config instead of hardcoded models.

Robust API key handling (supersedes #4, by @quinneydavid):
- Validate the required provider key before every call, treating empty or
  whitespace-only *_API_KEY values as missing (litellm.validate_environment
  alone reports empty keys as present).
- Fail fast with a clear error naming the env var to set; no silent,
  hardcoded provider fallback.
- Centralized in one _complete() helper, removing the duplicated
  completion() calls from the original PR.

Configurable at Docker launch:
- PLEXMUSE_MODEL sets the default model (any LiteLLM string -> any provider).
- PLEXMUSE_MODELS offers a UI dropdown of choices.
- New /config endpoint and injected window config expose these to the UI.

Tests: 21 -> 32 passing; pylint 10.00/10; flake8/black/isort clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@LubergAlexander
LubergAlexander merged commit a41fda3 into master Jul 21, 2026
2 checks passed
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.

1 participant