From 26700ac4ac6b307aa94abaf801d1e2dd3aa2e156 Mon Sep 17 00:00:00 2001 From: Liuzhch1 Date: Tue, 10 Sep 2024 19:22:05 +0800 Subject: [PATCH] fix: get OpenAI models only if OpenAI Enabled;timeout for query OpenAI models --- backend/open_webui/apps/audio/main.py | 2 +- .../components/admin/Settings/Connections.svelte | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/backend/open_webui/apps/audio/main.py b/backend/open_webui/apps/audio/main.py index 1fc44b28f..4cda34577 100644 --- a/backend/open_webui/apps/audio/main.py +++ b/backend/open_webui/apps/audio/main.py @@ -443,7 +443,7 @@ def get_available_models() -> list[dict]: try: response = requests.get( - "https://api.elevenlabs.io/v1/models", headers=headers + "https://api.elevenlabs.io/v1/models", headers=headers, timeout=5 ) response.raise_for_status() models = response.json() diff --git a/src/lib/components/admin/Settings/Connections.svelte b/src/lib/components/admin/Settings/Connections.svelte index fe71e4816..97a760110 100644 --- a/src/lib/components/admin/Settings/Connections.svelte +++ b/src/lib/components/admin/Settings/Connections.svelte @@ -150,18 +150,20 @@ })() ]); - OPENAI_API_BASE_URLS.forEach(async (url, idx) => { - const res = await getOpenAIModels(localStorage.token, idx); - if (res.pipelines) { - pipelineUrls[url] = true; - } - }); - const ollamaConfig = await getOllamaConfig(localStorage.token); const openaiConfig = await getOpenAIConfig(localStorage.token); ENABLE_OPENAI_API = openaiConfig.ENABLE_OPENAI_API; ENABLE_OLLAMA_API = ollamaConfig.ENABLE_OLLAMA_API; + + if (ENABLE_OPENAI_API) { + OPENAI_API_BASE_URLS.forEach(async (url, idx) => { + const res = await getOpenAIModels(localStorage.token, idx); + if (res.pipelines) { + pipelineUrls[url] = true; + } + }); + } } });