From d1c27e559f2d8cbe2066f0083a8e2ba967e3e0c5 Mon Sep 17 00:00:00 2001 From: Fujio Turner Date: Tue, 15 Sep 2026 15:48:53 -0500 Subject: [PATCH] Allow Analyze with AI for local Ollama without an API key. The Analyze button still required dataset.apiKey on the provider dropdown, so Local OpenAI-compatible always toasted even after a successful Test API. Skip that check for local-openai and store a dummy key when Settings is saved with the field empty. --- app/assets/js/main-legacy.js | 8 +++++--- app/assets/js/settings.js | 2 +- app/index.html | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/assets/js/main-legacy.js b/app/assets/js/main-legacy.js index e19938c3..6002032c 100644 --- a/app/assets/js/main-legacy.js +++ b/app/assets/js/main-legacy.js @@ -26853,10 +26853,11 @@ ${info.features.map((f) => ` • ${f}`).join("\n")} return; } } else { - // Standard provider - check API key + // Standard provider - check API key (local Ollama/LM Studio need none) + const localCompat = ['local-openai', 'ollama', 'lmstudio', 'vllm'].includes(provider); const hasApiKey = selectedOption?.dataset.apiKey && selectedOption.dataset.apiKey.length > 0; - if (!hasApiKey) { + if (!hasApiKey && !localCompat) { showToast('No API key configured for this provider. Please add in Settings.', 'error'); Logger.error('[AI] No API key for provider:', provider); return; @@ -27650,7 +27651,8 @@ ${info.features.map((f) => ` • ${f}`).join("\n")} // Store full API config as data attribute option.dataset.apiUrl = api.apiUrl; option.dataset.model = api.model; - option.dataset.apiKey = api.apiKey; + option.dataset.apiKey = api.apiKey || (localCompat ? 'ollama' : ''); + option.dataset.apiKeyOptional = localCompat ? 'true' : 'false'; if (hasApiKey) { hasUsableProvider = true; diff --git a/app/assets/js/settings.js b/app/assets/js/settings.js index 109ef27e..f9c67fd6 100644 --- a/app/assets/js/settings.js +++ b/app/assets/js/settings.js @@ -651,7 +651,7 @@ async function saveCurrentPreferences() { // Only update if field has value, otherwise keep existing (skip redaction markers) const existingKey = (existing?.apiKey && !existing.apiKey.startsWith('[REDACTED:')) ? existing.apiKey : ''; - const apiKey = apiKeyField || existingKey || ''; + const apiKey = apiKeyField || existingKey || (provider.apiKeyOptional ? 'ollama' : ''); const apiUrl = apiUrlField || existing?.apiUrl || provider.defaultUrl; return { diff --git a/app/index.html b/app/index.html index 86c276c4..402f9b49 100644 --- a/app/index.html +++ b/app/index.html @@ -148,7 +148,7 @@ - +