fix: non-ASCII stop sequences on a model reach the provider corrupted (#33614)

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
This commit is contained in:
Classic298 2026-11-03 12:44:05 +01:00 • committed by GitHub
parent 1d5373066d
commit dd6720c528
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,