Skip to content

fix(web): preselect the LLM_PROVIDER from .env in the provider picker - #318

Open
Danielgfonseca wants to merge 1 commit into
hydropix:mainfrom
Danielgfonseca:fix/web-ui-default-provider
Open

Danielgfonseca wants to merge 1 commit into
hydropix:mainfrom
Danielgfonseca:fix/web-ui-default-provider

Conversation

@Danielgfonseca

Copy link
Copy Markdown

Summary

LLM_PROVIDER is read by the server and the CLI, but it never reaches the web UI. In a browser with no saved choice (new device, private window, cleared storage) the provider select keeps its first option, Ollama, even when the server is configured for another provider. With no local Ollama the page then reports:

Ollama is not accessible at http://localhost:11434/api/generate or an error occurred.

Translations started after switching the select by hand work fine, so this is only the initial selection. The choice is only saved to localStorage on beforeunload or when saving settings, and mobile Safari rarely fires beforeunload, so on an iPhone the page falls back to Ollama on every visit.

This is the same family as #108 (DEFAULT_TARGET_LANGUAGE) and #153 (DEFAULT_MODEL).

Change

  • /api/config now returns llm_provider (_config.LLM_PROVIDER). /api/settings already exposed it, but the page builds its defaults from /api/config.
  • ProviderManager.applyServerDefaultProvider() runs when the default config is loaded, right before toggleProviderSettings(true), so models are loaded for the right provider. It only applies when the browser has no saved lastProvider, which means a provider the user picked before always wins. It also skips unknown values, and keeps the searchable select and its logo in sync.

Tests

  • New tests/unit/test_default_provider_exposed.py: /api/config returns the configured provider, and ollama when LLM_PROVIDER is unset. Both fail without the fix and pass with it.
  • pytest tests/unit: 1897 passed, 1 skipped, 1 failed. The failure is test_path_validator.py::test_reject_path_separator_backslash, which also fails on main on Linux and is unrelated.
  • The frontend part has no automated test, because the repo has no JS test harness. I applied the same change to a 1.5.17 deployment with LLM_PROVIDER=openai. There /api/config returns "llm_provider": "openai" and the patched provider-manager.js is served. node --check passes on the file.

The web UI never received LLM_PROVIDER, so in a browser with no saved
choice the provider select kept its first option (Ollama) even when the
server is configured for another provider, and the page reported
"Ollama is not accessible at http://localhost:11434/api/generate".

- /api/config now returns llm_provider.
- ProviderManager applies it once the default config is loaded, before
  loading models, only when the browser has no saved lastProvider. A
  provider the user picked before still wins.

Same family as hydropix#108 (DEFAULT_TARGET_LANGUAGE) and hydropix#153 (DEFAULT_MODEL).
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