From dd6720c528f891f9c13611630f39c0b61893c813 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Tue, 3 Nov 2026 12:44:05 +0100 Subject: [PATCH] fix: non-ASCII stop sequences on a model reach the provider corrupted (#33614) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A Stop Sequence saved on a workspace model reached the provider corrupted when it had non-ASCII text in it (終 went out as çµ\x82, café as café), so the model never stopped on it. This happened when an API client used the model through /openai/chat/completions or /ollama/api/chat. Those stops now arrive unchanged, and typing \n in the field still sends a newline. Fixes #33610 --- backend/open_webui/utils/payload.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/utils/payload.py b/backend/open_webui/utils/payload.py index d033fbfaab..f1befc53a8 100644 --- a/backend/open_webui/utils/payload.py +++ b/backend/open_webui/utils/payload.py @@ -210,7 +210,7 @@ def apply_model_params_to_body_openai(params: dict, form_data: dict) -> dict: 'presence_penalty': float, 'reasoning_effort': str, 'seed': lambda x: x, - 'stop': lambda x: [bytes(s, 'utf-8').decode('unicode_escape') for s in x], + 'stop': lambda x: [stop.encode('latin-1', 'backslashreplace').decode('unicode_escape') for stop in x], 'logit_bias': lambda x: x, 'response_format': dict, } @@ -264,7 +264,7 @@ def apply_model_params_to_body_ollama(params: dict, form_data: dict) -> dict: 'repeat_penalty': float, 'presence_penalty': float, 'frequency_penalty': float, - 'stop': lambda x: [bytes(s, 'utf-8').decode('unicode_escape') for s in x], + 'stop': lambda x: [stop.encode('latin-1', 'backslashreplace').decode('unicode_escape') for stop in x], 'num_gpu': int, 'use_mmap': bool, 'use_mlock': bool,