~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
Fix model dropdown showing wrong provider's models
LearningCircuit741fe7939152
diff --git a/src/local_deep_research/llm/providers/implementations/ollama.py b/src/local_deep_research/llm/providers/implementations/ollama.pyindex da8c0f10a7..3f339dfd14 100644--- a/src/local_deep_research/llm/providers/implementations/ollama.py+++ b/src/local_deep_research/llm/providers/implementations/ollama.py@@ -71,11 +71,14 @@ class OllamaProvider:return headers@classmethod- def list_models_for_api(cls, api_key=None, settings_snapshot=None):+ def list_models_for_api(+ cls, api_key=None, base_url=None, settings_snapshot=None+ ):"""Get available models from Ollama.Args:api_key: Optional API key for authentication+ base_url: Optional base URL for Ollama APIsettings_snapshot: Optional settings snapshot for configurationReturns:@@ -83,12 +86,13 @@ class OllamaProvider:"""from ....utilities.llm_utils import fetch_ollama_models- # Get Ollama URL from settings- base_url = get_setting_from_snapshot(- "llm.ollama.url",- default=None,- settings_snapshot=settings_snapshot,- )+ # Use provided base_url, or get from settings_snapshot+ if not base_url and settings_snapshot:+ base_url = get_setting_from_snapshot(+ "llm.ollama.url",+ default=None,+ settings_snapshot=settings_snapshot,+ )if not base_url:logger.warning("Ollama URL not configured")diff --git a/src/local_deep_research/web/routes/settings_routes.py b/src/local_deep_research/web/routes/settings_routes.pyindex d7c10f44eb..1047f18ebc 100644--- a/src/local_deep_research/web/routes/settings_routes.py+++ b/src/local_deep_research/web/routes/settings_routes.py@@ -1387,7 +1387,9 @@ def api_get_available_models():provider_models.append({"value": model["value"],- "label": f"{model['label']} ({provider_key})",+ "label": model[+ "label"+ ], # Use provider's label as-is"provider": provider_key,})diff --git a/src/local_deep_research/web/static/js/components/research.js b/src/local_deep_research/web/static/js/components/research.jsindex 9404265376..9458e129c0 100644--- a/src/local_deep_research/web/static/js/components/research.js+++ b/src/local_deep_research/web/static/js/components/research.js@@ -41,7 +41,6 @@const CACHE_EXPIRATION = 24 * 60 * 60 * 1000;// Flag to track if we're using fallback data- let usingFallbackModels = false;let usingFallbackSearchEngines = false;// State variables for dropdowns@@ -870,213 +869,15 @@console.log('Filtering models for provider:', providerUpper, 'from', allModels.length, 'models');// Filter models based on provider- let models = [];-- // Special handling for OLLAMA provider - don't do strict filtering- if (providerUpper === 'OLLAMA') {- console.log('Searching for Ollama models...');-- // First attempt: get models with provider explicitly set to OLLAMA- models = allModels.filter(model => {+ // Simple filtering: only show models from the selected provider+ const models = allModels.filter(model => {if (!model || typeof model !== 'object') return false;- // Check if provider is set to OLLAMA+ // Skip provider options (they have value but no id)+ if (model.value && !model.id && !model.name) return false;const modelProvider = (model.provider || '').toUpperCase();- return modelProvider === 'OLLAMA';+ return modelProvider === providerUpper;});- console.log(`Found ${models.length} models with provider="OLLAMA"`);-- // If we didn't find enough models, look for models with Ollama in the name or id- if (models.length < 2) {- console.log('Searching more broadly for Ollama models');- models = allModels.filter(model => {- if (!model || typeof model !== 'object') return false;-- // Skip provider options that are not actual models- if (model.value && !model.id && !model.name) return false;-- // Check various properties that might indicate this is an Ollama model- const modelProvider = (model.provider || '').toUpperCase();- const modelName = (model.name || model.label || '').toLowerCase();- const modelId = (model.id || model.value || '').toLowerCase();-- // Include if: provider is OLLAMA OR name contains "ollama" OR id is one of common Ollama models- return modelProvider === 'OLLAMA' ||- modelName.includes('ollama') ||- modelId.includes('llama') ||- modelId.includes('mistral') ||- modelId.includes('gemma');- });-- console.log(`Broader search found ${models.length} possible Ollama models`);- }-- // If we still don't have enough models, look for any that might be LLMs- if (models.length < 2) {- console.log('Still few models found, trying any model with likely LLM names');- // Add models that look like they could be LLMs (if they're not already included)- const moreModels = allModels.filter(model => {- if (!model || typeof model !== 'object') return false;- if (models.some(m => m.id === model.id || m.value === model.value)) return false; // Skip if already included-- const modelId = (model.id || model.value || '').toLowerCase();- const modelName = (model.name || model.label || '').toLowerCase();-- // Include common LLM name patterns- return modelId.includes('gpt') ||- modelId.includes('llama') ||- modelId.includes('mistral') ||- modelId.includes('gemma') ||- modelId.includes('claude') ||- modelName.includes('llm') ||- modelName.includes('model');- });-- console.log(`Found ${moreModels.length} additional possible LLM models`);- models = [...models, ...moreModels];- }-- // If we STILL have few or no models, use our fallbacks- if (models.length < 2) {- console.log('No Ollama models found, using fallbacks');- models = [- { id: 'llama3', name: 'Llama 3 (Ollama)', provider: 'OLLAMA' },- { id: 'mistral', name: 'Mistral (Ollama)', provider: 'OLLAMA' },- { id: 'gemma:latest', name: 'Gemma (Ollama)', provider: 'OLLAMA' }- ];- usingFallbackModels = true;- }- } else if (providerUpper === 'ANTHROPIC') {- // Filter Anthropic models- models = allModels.filter(model => {- if (!model || typeof model !== 'object') return false;-- // Skip provider options- if (model.value && !model.id && !model.name) return false;-- // Check provider, name, or ID for Anthropic indicators- const modelProvider = (model.provider || '').toUpperCase();- const modelName = (model.name || model.label || '').toLowerCase();- const modelId = (model.id || model.value || '').toLowerCase();-- return modelProvider === 'ANTHROPIC' ||- modelName.includes('claude') ||- modelId.includes('claude');- });-- // Add fallbacks if necessary- if (models.length === 0) {- console.log('No Anthropic models found, using fallbacks');- models = [- { id: 'claude-3-5-sonnet-latest', name: 'Claude 3.5 Sonnet (Anthropic)', provider: 'ANTHROPIC' },- { id: 'claude-3-opus-20240229', name: 'Claude 3 Opus (Anthropic)', provider: 'ANTHROPIC' },- { id: 'claude-3-sonnet-20240229', name: 'Claude 3 Sonnet (Anthropic)', provider: 'ANTHROPIC' }- ];- usingFallbackModels = true;- }- } else if (providerUpper === 'OPENAI') {- // Filter OpenAI models- models = allModels.filter(model => {- if (!model || typeof model !== 'object') return false;-- // Skip provider options- if (model.value && !model.id && !model.name) return false;-- // Check provider, name, or ID for OpenAI indicators- const modelProvider = (model.provider || '').toUpperCase();- const modelName = (model.name || model.label || '').toLowerCase();- const modelId = (model.id || model.value || '').toLowerCase();-- return modelProvider === 'OPENAI' ||- modelName.includes('gpt') ||- modelId.includes('gpt');- });-- // Add fallbacks if necessary- if (models.length === 0) {- console.log('No OpenAI models found, using fallbacks');- models = [- { id: 'gpt-4o', name: 'GPT-4o (OpenAI)', provider: 'OPENAI' },- { id: 'gpt-4', name: 'GPT-4 (OpenAI)', provider: 'OPENAI' },- { id: 'gpt-3.5-turbo', name: 'GPT-3.5 Turbo (OpenAI)', provider: 'OPENAI' }- ];- usingFallbackModels = true;- }- } else if (providerUpper === 'OPENAI_ENDPOINT') {- models = allModels.filter(model => {- if (!model || typeof model !== 'object') return false;-- // Skip provider options- if (model.value && !model.id && !model.name) return false;-- const modelProvider = (model.provider || '').toUpperCase();- return modelProvider === 'OPENAI_ENDPOINT';- });-- console.log(`Found ${models.length} models with provider="OPENAI_ENDPOINT"`);-- if (models.length === 0) {- console.log('No OPENAI_ENDPOINT models found, checking for models with "Custom" in label');- models = allModels.filter(model => {- if (!model || typeof model !== 'object') return false;-- // Skip provider options- if (model.value && !model.id && !model.name) return false;-- const modelLabel = (model.label || '').toLowerCase();- return modelLabel.includes('custom');- });-- console.log(`Found ${models.length} models with "Custom" in label`);- }-- if (models.length === 0) {- console.log('No OPENAI_ENDPOINT or Custom models found, using OpenAI models as examples');- models = allModels.filter(model => {- if (!model || typeof model !== 'object') return false;-- // Skip provider options- if (model.value && !model.id && !model.name) return false;-- const modelProvider = (model.provider || '').toUpperCase();- const modelId = (model.id || model.value || '').toLowerCase();- return modelProvider === 'OPENAI' ||- modelId.includes('gpt');- });- }-- // Add fallbacks if necessary- if (models.length === 0) {- console.log('No models found for custom endpoint, using fallbacks');- models = [- { id: 'gpt-4o', name: 'GPT-4o (via Custom Endpoint)', provider: 'OPENAI_ENDPOINT' },- { id: 'claude-3-5-sonnet-latest', name: 'Claude 3.5 Sonnet (via Custom Endpoint)', provider: 'OPENAI_ENDPOINT' }- ];- usingFallbackModels = true;- }- } else {- // Standard filtering for other providers- models = allModels.filter(model => {- if (!model || typeof model !== 'object') return false;-- // Skip provider options (they have value but no id)- if (model.value && !model.id && !model.name) return false;-- const modelProvider = model.provider ? model.provider.toUpperCase() : '';- return modelProvider === providerUpper;- });-- // If we found no models for this provider, add fallbacks- if (models.length === 0) {- console.log(`No models found for provider ${provider}, using generic fallbacks`);- models = [- { id: 'model1', name: `Model 1 (${providerUpper})`, provider: providerUpper },- { id: 'model2', name: `Model 2 (${providerUpper})`, provider: providerUpper }- ];- usingFallbackModels = true;- }- }-console.log('Filtered models for provider', provider, ':', models.length, 'models');// Format models for dropdown@@ -1752,12 +1553,9 @@console.log('Using expired cached model data due to API error');resolve(cachedData);} else {- // Use fallback data if no cache available- console.log('Using fallback model data');- const fallbackModels = getFallbackModels();- cacheData(CACHE_KEYS.MODELS, fallbackModels);- cacheData('deepResearch.availableModels', fallbackModels);- resolve(fallbackModels);+ // No cache and API failed - return empty array+ console.log('API failed and no cache available - returning empty model list');+ resolve([]);}});});@@ -1815,26 +1613,6 @@return formatted;}- // Get fallback models if API fails- function getFallbackModels() {- return [- // Ollama models- { id: 'llama3', value: 'llama3', label: 'Llama 3 (Ollama)', provider: 'OLLAMA' },- { id: 'mistral', value: 'mistral', label: 'Mistral (Ollama)', provider: 'OLLAMA' },- { id: 'gemma:latest', value: 'gemma:latest', label: 'Gemma (Ollama)', provider: 'OLLAMA' },-- // OpenAI models- { id: 'gpt-4o', value: 'gpt-4o', label: 'GPT-4o (OpenAI)', provider: 'OPENAI' },- { id: 'gpt-4', value: 'gpt-4', label: 'GPT-4 (OpenAI)', provider: 'OPENAI' },- { id: 'gpt-3.5-turbo', value: 'gpt-3.5-turbo', label: 'GPT-3.5 Turbo (OpenAI)', provider: 'OPENAI' },-- // Anthropic models- { id: 'claude-3-5-sonnet-latest', value: 'claude-3-5-sonnet-latest', label: 'Claude 3.5 Sonnet (Anthropic)', provider: 'ANTHROPIC' },- { id: 'claude-3-opus-20240229', value: 'claude-3-opus-20240229', label: 'Claude 3 Opus (Anthropic)', provider: 'ANTHROPIC' },- { id: 'claude-3-sonnet-20240229', value: 'claude-3-sonnet-20240229', label: 'Claude 3 Sonnet (Anthropic)', provider: 'ANTHROPIC' }- ];- }-// In-memory cache to avoid excessive API calls within a sessionconst memoryCache = {};const CACHE_DURATION = 5 * 60 * 1000; // 5 minutes