From d12afc6039c4ee1316b3633602035be361edff85 Mon Sep 17 00:00:00 2001 From: expruc Date: Thu, 2 Oct 2025 22:26:24 +0300 Subject: [PATCH 001/606] improved query pref by querying only relevant columns --- backend/open_webui/models/files.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/models/files.py b/backend/open_webui/models/files.py index bf07b5f86f..c5cbaf91f8 100644 --- a/backend/open_webui/models/files.py +++ b/backend/open_webui/models/files.py @@ -186,7 +186,9 @@ class FilesTable: created_at=file.created_at, updated_at=file.updated_at, ) - for file in db.query(File) + for file in db.query( + File.id, File.meta, File.created_at, File.updated_at + ) .filter(File.id.in_(ids)) .order_by(File.updated_at.desc()) .all() From f25b7b73b4d4f7a3d60f79091797a10fe9a7f530 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 3 Oct 2025 00:23:26 -0500 Subject: [PATCH 002/606] refac: openai additional headers support --- backend/open_webui/routers/openai.py | 3 + src/lib/components/AddConnectionModal.svelte | 65 +++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/routers/openai.py b/backend/open_webui/routers/openai.py index e8865b90a0..8c5e3da736 100644 --- a/backend/open_webui/routers/openai.py +++ b/backend/open_webui/routers/openai.py @@ -190,6 +190,9 @@ async def get_headers_and_cookies( if token: headers["Authorization"] = f"Bearer {token}" + if config.get("headers") and isinstance(config.get("headers"), dict): + headers = {**headers, **config.get("headers")} + return headers, cookies diff --git a/src/lib/components/AddConnectionModal.svelte b/src/lib/components/AddConnectionModal.svelte index 240df839a8..784b3c0453 100644 --- a/src/lib/components/AddConnectionModal.svelte +++ b/src/lib/components/AddConnectionModal.svelte @@ -17,6 +17,7 @@ import Tags from './common/Tags.svelte'; import Spinner from '$lib/components/common/Spinner.svelte'; import XMark from '$lib/components/icons/XMark.svelte'; + import Textarea from './common/Textarea.svelte'; export let onSubmit: Function = () => {}; export let onDelete: Function = () => {}; @@ -42,6 +43,8 @@ let enable = true; let apiVersion = ''; + let headers = ''; + let tags = []; let modelId = ''; @@ -69,6 +72,19 @@ // remove trailing slash from url url = url.replace(/\/$/, ''); + if (headers) { + try { + const _headers = JSON.parse(headers); + if (typeof _headers !== 'object' || Array.isArray(_headers)) { + throw new Error('Headers must be a valid JSON object'); + } + headers = JSON.stringify(_headers, null, 2); + } catch (error) { + toast.error($i18n.t('Headers must be a valid JSON object')); + return; + } + } + const res = await verifyOpenAIConnection( localStorage.token, { @@ -77,7 +93,8 @@ config: { auth_type, azure: azure, - api_version: apiVersion + api_version: apiVersion, + headers: JSON.parse(headers) } }, direct @@ -136,6 +153,19 @@ } } + if (headers) { + try { + const _headers = JSON.parse(headers); + if (typeof _headers !== 'object' || Array.isArray(_headers)) { + throw new Error('Headers must be a valid JSON object'); + } + headers = JSON.stringify(_headers, null, 2); + } catch (error) { + toast.error($i18n.t('Headers must be a valid JSON object')); + return; + } + } + // remove trailing slash from url url = url.replace(/\/$/, ''); @@ -149,6 +179,7 @@ model_ids: modelIds, connection_type: connectionType, auth_type, + headers: headers ? JSON.parse(headers) : undefined, ...(!ollama && azure ? { azure: true, api_version: apiVersion } : {}) } }; @@ -172,6 +203,9 @@ key = connection.key; auth_type = connection.config.auth_type ?? 'bearer'; + headers = connection.config?.headers + ? JSON.stringify(connection.config.headers, null, 2) + : ''; enable = connection.config?.enable ?? true; tags = connection.config?.tags ?? []; @@ -376,6 +410,35 @@ + {#if !ollama && !direct} +
+
+ + +
+ + {/if}
diff --git a/src/lib/components/workspace/Prompts/PromptEditor.svelte b/src/lib/components/workspace/Prompts/PromptEditor.svelte index de71a1cb9b..21868be80e 100644 --- a/src/lib/components/workspace/Prompts/PromptEditor.svelte +++ b/src/lib/components/workspace/Prompts/PromptEditor.svelte @@ -106,7 +106,7 @@