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: train ShareGPT tool calls natively on processor-loaded models (#13824)
Daniel Han361e82599203
diff --git a/studio/backend/tests/test_chat_template_tool_call_rows.py b/studio/backend/tests/test_chat_template_tool_call_rows.pyindex e4b54a04b3c..484c46f5e32 100644--- a/studio/backend/tests/test_chat_template_tool_call_rows.py+++ b/studio/backend/tests/test_chat_template_tool_call_rows.py@@ -259,6 +259,31 @@ def test_sharegpt_function_call_and_observation_train_as_tool_turns():assert "observation" not in text+class _JinjaProcessor(_JinjaTokenizer):+ # Processor-shaped: the standardizer wraps every turn in text parts.+ @property+ def tokenizer(self):+ return self+++def test_sharegpt_tool_turns_train_natively_on_a_processor_loaded_gemma4():+ call = json.dumps({"name": "get_weather", "arguments": {"city": "Paris"}})++ result = format_and_template_dataset(+ Dataset.from_list([_sharegpt_tool_row(call)]),+ model_name = "stub-model",+ tokenizer = _JinjaProcessor(_GEMMA4_TEMPLATE.read_text(encoding = "utf-8")),+ num_proc = 1,+ )++ assert result["success"] is True, result["errors"]+ text = result["dataset"][0]["text"]+ assert 'call:get_weather{city:<|"|>Paris<|"|>}' in text+ assert "<|tool_response>" in text+ assert "function_call" not in text+ assert "observation" not in text++def test_sharegpt_function_call_list_trains_every_call():call = json.dumps([diff --git a/studio/backend/utils/datasets/chat_templates.py b/studio/backend/utils/datasets/chat_templates.pyindex 1b19c48f1c9..ed812fb5abd 100644--- a/studio/backend/utils/datasets/chat_templates.py+++ b/studio/backend/utils/datasets/chat_templates.py@@ -236,8 +236,16 @@ def _sharegpt_tool_turns(conversation, content = "", probe = False):markers.append(f"unslothresult{len(markers)}end")message["content"] = markers[-1]elif role == "function_call":+ raw = message.get("content")+ if isinstance(raw, list):+ # A processor-loaded model gets every turn standardized into text parts.+ raw = "".join(+ part.get("text") or ""+ for part in raw+ if isinstance(part, dict) and part.get("type") == "text"+ )try:- calls = json.loads(message.get("content"))+ calls = json.loads(raw)except (TypeError, ValueError, RecursionError):calls = Nonecalls = calls if isinstance(calls, list) else [calls]