From 30a13b9b2fb2c6da7e1ddbf52edb93a58d09cc56 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sun, 22 Feb 2026 17:11:50 -0600 Subject: [PATCH] refac: ollama str think support --- backend/open_webui/utils/payload.py | 4 +- .../Settings/Advanced/AdvancedParams.svelte | 56 +++++++++++++------ 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/backend/open_webui/utils/payload.py b/backend/open_webui/utils/payload.py index 318b8f8f88..168ec893b2 100644 --- a/backend/open_webui/utils/payload.py +++ b/backend/open_webui/utils/payload.py @@ -187,7 +187,7 @@ def apply_model_params_to_body_ollama(params: dict, form_data: dict) -> dict: ollama_root_params = { "format": lambda x: parse_json(x), "keep_alive": lambda x: parse_json(x), - "think": bool, + "think": lambda x: x, } for key, value in ollama_root_params.items(): @@ -326,7 +326,7 @@ def convert_payload_openai_to_ollama(openai_payload: dict) -> dict: ollama_root_params = { "format": lambda x: parse_json(x), "keep_alive": lambda x: parse_json(x), - "think": bool, + "think": lambda x: x, } # Ollama's options field can contain parameters that should be at the root level. diff --git a/src/lib/components/chat/Settings/Advanced/AdvancedParams.svelte b/src/lib/components/chat/Settings/Advanced/AdvancedParams.svelte index 046dc6b042..446ec8823a 100644 --- a/src/lib/components/chat/Settings/Advanced/AdvancedParams.svelte +++ b/src/lib/components/chat/Settings/Advanced/AdvancedParams.svelte @@ -1233,23 +1233,47 @@ {'think'} ({$i18n.t('Ollama')}) + class="p-1 px-3 text-xs flex rounded-sm transition" + on:click={() => { + if ((params?.think ?? null) === null) { + params.think = true; + } else if (params.think === true) { + params.think = 'medium'; + } else if (typeof params.think === 'string') { + params.think = false; + } else { + params.think = null; + } + }} + type="button" + > + {#if params.think === true} + {$i18n.t('On')} + {:else if params.think === false} + {$i18n.t('Off')} + {:else if typeof params.think === 'string'} + {$i18n.t('Custom')} + {:else} + {$i18n.t('Default')} + {/if} + + + + + {#if typeof params.think === 'string'} +
+
+
- -
+ + {/if} +