Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: keep angle-bracket text in user turns on the safetensors fallback formatter (#17562)
oobabooga37282c3e331e
diff --git a/studio/backend/core/inference/inference.py b/studio/backend/core/inference/inference.pyindex f10852329d7..51cf8cd23ae 100644--- a/studio/backend/core/inference/inference.py+++ b/studio/backend/core/inference/inference.py@@ -3779,13 +3779,8 @@ class InferenceBackend:continueif role == "user":- import re- clean_content = re.sub(r"<[^>]+>", "", content).strip()- if clean_content:- chat_messages.append(- named_turn({"role": role, "content": clean_content}, msg)- )- last_role = role+ chat_messages.append(named_turn({"role": role, "content": content}, msg))+ last_role = roleelif role == "assistant":assistant_message = named_turn({"role": role, "content": content}, msg)if has_reasoning_content:diff --git a/studio/backend/tests/test_chat_template_continuation.py b/studio/backend/tests/test_chat_template_continuation.pyindex f04d7095338..5dda24a725d 100644--- a/studio/backend/tests/test_chat_template_continuation.py+++ b/studio/backend/tests/test_chat_template_continuation.py@@ -568,6 +568,40 @@ def test_native_fallback_keeps_participant_names():assert seen["messages"] == conversation+def _templateless_backend():+ InferenceBackend = _inference_backend()++ class _Tokenizer:+ chat_template = None++ def apply_chat_template(self, *_args, **_kwargs):+ raise ValueError("tokenizer.chat_template is not set")++ backend = InferenceBackend.__new__(InferenceBackend)+ backend.active_model_name = "m"+ backend.models = {"m": {"tokenizer": _Tokenizer(), "chat_template_info": {}}}+ return backend+++ "text",+ ["Why does std::vector<int> fail?", "Is a < b when b > c?", "Fix <div>hi</div>"],+)+def test_fallback_keeps_angle_bracket_text_in_user_turns(text):+ prompt = _templateless_backend().format_chat_prompt([{"role": "user", "content": text}])+ assert prompt == f"User: {text}\nAssistant: "+++def test_fallback_keeps_a_markup_only_final_user_turn():+ conversation = [+ {"role": "user", "content": "What is 2+2?"},+ {"role": "assistant", "content": "4"},+ {"role": "user", "content": "<div><span>"},+ ]+ prompt = _templateless_backend().format_chat_prompt(conversation)+ assert prompt.endswith("Assistant: 4\nUser: <div><span>\nAssistant: ")++def test_a_text_part_partial_merges_rather_than_doubling_the_turn():"""Text partials merge into one assistant turn; strict templates reject a doubled turn."""conversation = [