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.

Merge dev branch and resolve conflicts with xAI provider integration

LearningCircuit6b2174f732fa
diff --cc src/local_deep_research/llm/providers/__init__.py
index 673bd3f23e,3b87867b28..318729f2f3
--- a/src/local_deep_research/llm/providers/__init__.py
+++ b/src/local_deep_research/llm/providers/__init__.py
@@@ -1,18 -1,16 +1,20 @@@
"""LLM Providers module for Local Deep Research."""
- from .google import register_google_provider
- from .openrouter import register_openrouter_provider
+ from .auto_discovery import (
+ discover_providers,
+ get_discovered_provider_options,
+ get_provider_class,
+ )
+from .xai import register_xai_provider
- from .openai_base import GenericOpenAIEndpoint
__all__ = [
- "register_google_provider",
- "register_openrouter_provider",
+ "discover_providers",
+ "get_discovered_provider_options",
+ "get_provider_class",
+ "register_xai_provider",
- "GenericOpenAIEndpoint",
]
- # Auto-register providers on import
- register_google_provider()
- register_openrouter_provider()
+ # Auto-discover and register all providers on import
+ discover_providers()
++# Register xAI provider
+register_xai_provider()
diff --cc src/local_deep_research/web/routes/settings_routes.py
index 512a275d65,3dac2e08c3..4d3899b613
--- a/src/local_deep_research/web/routes/settings_routes.py
+++ b/src/local_deep_research/web/routes/settings_routes.py
@@@ -933,19 -936,18 +936,21 @@@ def api_get_available_models()
request.args.get("force_refresh", "false").lower() == "true"
)
- # Define provider options with generic provider names
- provider_options = [
- {"value": "OLLAMA", "label": "Ollama (Local)"},
- {"value": "OPENAI", "label": "OpenAI (Cloud)"},
- {"value": "ANTHROPIC", "label": "Anthropic (Cloud)"},
- {"value": "GOOGLE", "label": "Google Gemini (Cloud)"},
- {"value": "OPENROUTER", "label": "OpenRouter (Cloud)"},
- {"value": "XAI", "label": "xAI Grok (Cloud)"},
- {"value": "OPENAI_ENDPOINT", "label": "Custom OpenAI Endpoint"},
- {"value": "VLLM", "label": "vLLM (Local)"},
- {"value": "LMSTUDIO", "label": "LM Studio (Local)"},
- {"value": "LLAMACPP", "label": "Llama.cpp (Local)"},
- ]
+ # Get all auto-discovered providers
+ from ...llm.providers import get_discovered_provider_options
+
+ provider_options = get_discovered_provider_options()
+
++ # Add xAI provider
++ provider_options.append({"value": "XAI", "label": "xAI Grok (Cloud)"})
++
+ # Add remaining hardcoded providers (complex local providers not yet migrated)
+ provider_options.extend(
+ [
+ {"value": "VLLM", "label": "vLLM (Local)"},
+ {"value": "LLAMACPP", "label": "Llama.cpp (Local)"},
+ ]
+ )
# Available models by provider
providers = {}
@@@ -1358,108 -1357,54 +1360,87 @@@
providers["anthropic_models"] = anthropic_models
logger.info(f"Final Anthropic models count: {len(anthropic_models)}")
- # Try to get Google Gemini models using the provider class
- google_models = []
- try:
- logger.info("Fetching Google Gemini models")
+ # Fetch models from auto-discovered providers
+ from ...llm.providers import discover_providers
- from ...llm.providers.google import GoogleProvider
+ discovered_providers = discover_providers()
- # Get API key if configured (Google doesn't require it for listing models)
- api_key = _get_setting_from_session("llm.google.api_key", "")
-
- # Use the provider's list_models_for_api method
- models = GoogleProvider.list_models_for_api(api_key)
-
- # Format models for the API response
- for model in models:
- google_models.append(
- {
- "value": model["value"],
- "label": f"{model['label']} (Google)",
- "provider": "GOOGLE",
- }
+ for provider_key, provider_info in discovered_providers.items():
+ provider_models = []
+ try:
+ logger.info(
+ f"Fetching models from {provider_info.provider_name}"
)
- logger.info(
- f"Successfully fetched {len(google_models)} models from Google Gemini"
- )
-
- except Exception as e:
- logger.exception(f"Error getting Google Gemini models: {e!s}")
+ # Get the provider class
+ provider_class = provider_info.provider_class
- # Set google_models in providers
- providers["google_models"] = google_models
- logger.info(f"Final Google models count: {len(google_models)}")
-
- # Try to get OpenRouter models using the provider class
- openrouter_models = []
- try:
- logger.info("Fetching OpenRouter models")
+ # Get API key if configured
+ api_key = _get_setting_from_session(
+ provider_class.api_key_setting, ""
+ )
- from ...llm.providers.openrouter import OpenRouterProvider
+ # Use the provider's list_models_for_api method
+ models = provider_class.list_models_for_api(api_key)
- # Get API key if configured (OpenRouter doesn't require it for listing models)
- api_key = _get_setting_from_session("llm.openrouter.api_key", "")
+ # Format models for the API response
+ for model in models:
+ provider_models.append(
+ {
+ "value": model["value"],
+ "label": f"{model['label']} ({provider_key})",
+ "provider": provider_key,
+ }
+ )
- # Use the provider's list_models_for_api method
- models = OpenRouterProvider.list_models_for_api(api_key)
+ logger.info(
+ f"Successfully fetched {len(provider_models)} models from {provider_info.provider_name}"
+ )
- # Format models for the API response
- for model in models:
- openrouter_models.append(
- {
- "value": model["value"],
- "label": f"{model['label']} (OpenRouter)",
- "provider": "OPENROUTER",
- }
+ except Exception as e:
+ logger.exception(
+ f"Error getting {provider_info.provider_name} models: {e!s}"
)
+ # Set models in providers dict using lowercase key
+ providers[f"{provider_key.lower()}_models"] = provider_models
logger.info(
- f"Successfully fetched {len(openrouter_models)} models from OpenRouter"
+ f"Final {provider_key} models count: {len(provider_models)}"
)
- except Exception as e:
- logger.exception(f"Error getting OpenRouter models: {e!s}")
-
- # Set openrouter_models in providers
- providers["openrouter_models"] = openrouter_models
- logger.info(f"Final OpenRouter models count: {len(openrouter_models)}")
-
+ # Try to get xAI models using the provider class
+ xai_models = []
+ try:
+ logger.info("Fetching xAI Grok models")
+
+ from ...llm.providers.xai import XAIProvider
+
+ # Get API key if configured (xAI requires it for listing 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)
+
+ # Format models for the API response
+ for model in models:
+ xai_models.append(
+ {
+ "value": model["value"],
+ "label": f"{model['label']} (xAI)",
+ "provider": "XAI",
+ }
+ )
+
+ logger.info(
+ f"Successfully fetched {len(xai_models)} models from xAI"
+ )
+
+ except Exception as e:
+ logger.exception(f"Error getting xAI models: {e!s}")
+
+ # Set xai_models in providers
+ providers["xai_models"] = xai_models
+ logger.info(f"Final xAI models count: {len(xai_models)}")
-
# Save fetched models to database cache
if force_refresh or providers:
# We fetched fresh data, save it to database