Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(web): pass settings_snapshot to list_models_for_api calls

LearningCircuit1e0cf48c9254
diff --git a/src/local_deep_research/web/routes/settings_routes.py b/src/local_deep_research/web/routes/settings_routes.py
index 22c6d8d655..dfd1c300f6 100644
--- a/src/local_deep_research/web/routes/settings_routes.py
+++ b/src/local_deep_research/web/routes/settings_routes.py
@@ -1242,39 +1242,34 @@ def api_get_available_models():
)
if endpoint_url and api_key:
- # Need to temporarily set the URL for the provider class
- original_url = CustomOpenAIEndpointProvider.default_base_url
- CustomOpenAIEndpointProvider.default_base_url = endpoint_url
+ # Create settings snapshot with the URL to avoid race conditions
+ # (don't modify class attributes which could affect other requests)
+ settings_snapshot = {"llm.openai_endpoint.url": endpoint_url}
- try:
- # Use the provider's list_models_for_api method
- models = CustomOpenAIEndpointProvider.list_models_for_api(
- api_key
- )
-
- # Format models for the API response
- for model in models:
- # Create a clean display name
- display_name = model["label"].replace("-", " ").strip()
- display_name = " ".join(
- word.capitalize() for word in display_name.split()
- )
+ # Use the provider's list_models_for_api method with snapshot
+ models = CustomOpenAIEndpointProvider.list_models_for_api(
+ api_key, settings_snapshot
+ )
- openai_endpoint_models.append(
- {
- "value": model["value"],
- "label": f"{display_name} (Custom)",
- "provider": "OPENAI_ENDPOINT",
- }
- )
+ # Format models for the API response
+ for model in models:
+ # Create a clean display name
+ display_name = model["label"].replace("-", " ").strip()
+ display_name = " ".join(
+ word.capitalize() for word in display_name.split()
+ )
- logger.info(
- f"Successfully fetched {len(openai_endpoint_models)} models from Custom OpenAI Endpoint"
+ openai_endpoint_models.append(
+ {
+ "value": model["value"],
+ "label": f"{display_name} (Custom)",
+ "provider": "OPENAI_ENDPOINT",
+ }
)
- finally:
- # Restore original URL
- CustomOpenAIEndpointProvider.default_base_url = original_url
+ logger.info(
+ f"Successfully fetched {len(openai_endpoint_models)} models from Custom OpenAI Endpoint"
+ )
else:
logger.info(
@@ -1436,8 +1431,22 @@ def api_get_available_models():
provider_class.api_key_setting, ""
)
+ # Create settings snapshot with URL if provider has configurable URL
+ settings_snapshot = None
+ if (
+ hasattr(provider_class, "url_setting")
+ and provider_class.url_setting
+ ):
+ url = _get_setting_from_session(
+ provider_class.url_setting, ""
+ )
+ if url:
+ settings_snapshot = {provider_class.url_setting: url}
+
# Use the provider's list_models_for_api method
- models = provider_class.list_models_for_api(api_key)
+ models = provider_class.list_models_for_api(
+ api_key, settings_snapshot
+ )
# Format models for the API response
for model in models:
@@ -1475,7 +1484,8 @@ def api_get_available_models():
api_key = _get_setting_from_session("llm.xai.api_key", "")
# Use the provider's list_models_for_api method
- models = XAIProvider.list_models_for_api(api_key)
+ # XAI has fixed URL, no settings_snapshot needed
+ models = XAIProvider.list_models_for_api(api_key, None)
# Format models for the API response
for model in models: