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 non-English text in structured Laya instructions (#16510)
Nilay4d77df243c70
diff --git a/studio/backend/core/systemone/laya_runtime.py b/studio/backend/core/systemone/laya_runtime.pyindex 14b331f1d62..a126e6887f6 100644--- a/studio/backend/core/systemone/laya_runtime.py+++ b/studio/backend/core/systemone/laya_runtime.py@@ -1804,11 +1804,14 @@ def _agent_for(checkpoint: Checkpoint, wait: float):def _to_laya(question: dict[str, Any], name = "") -> dict[str, Any]:+ import json+instructions = question.get("instructions")- out = {- "type": question["type"],- "instructions": str(name) if instructions in (None, "") else instructions,- }+ if instructions in (None, ""):+ instructions = str(name)+ elif not isinstance(instructions, str):+ instructions = json.dumps(instructions, ensure_ascii = False)+ out = {"type": question["type"], "instructions": instructions}if question.get("criteria") is not None:out["criteria"] = question["criteria"]return outdiff --git a/studio/backend/tests/test_systemone.py b/studio/backend/tests/test_systemone.pyindex e5671ed9111..f9f24c25faa 100644--- a/studio/backend/tests/test_systemone.py+++ b/studio/backend/tests/test_systemone.py@@ -2,6 +2,7 @@# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import asyncio+import jsonimport osimport sysimport threading@@ -223,14 +224,14 @@ def test_question_without_instructions_is_asked_by_its_id(client, runtime, instr@pytest.mark.parametrize("instructions", [{}, [], {"prompt": "Refund?"}, ["Refund?"]])-def test_structured_question_instructions_are_forwarded_unchanged(client, instructions):+def test_structured_question_instructions_are_sent_as_json_text(client, instructions):response = _post(client,questions = {"refund": {"type": "noul", "instructions": instructions}},)assert response.status_code == 200, response.text_, questions = laya_runtime._agent.calls[-1]- assert questions["refund"]["instructions"] == instructions+ assert questions["refund"]["instructions"] == json.dumps(instructions, ensure_ascii = False)def test_named_checkpoint_swaps_the_resident_model(client, runtime):@@ -1393,6 +1394,7 @@ class WordTokenizer:def __init__(self):self.calls = []+ self.texts = []def __call__(self,@@ -1400,6 +1402,7 @@ class WordTokenizer:add_special_tokens = False,):self.calls.append(len(text))+ self.texts.append(text)return {"input_ids": [len(word) for word in text.split()]}@@ -1499,6 +1502,13 @@ def test_choice_instructions_laya_would_cut_are_refused(assert "answers" not in response.json()[email protected]("instructions", [{"ask": "これは緊急ですか"}, ["これは緊急ですか"]])+def test_structured_instructions_reach_laya_as_written(client, word_laya, instructions):+ question = {"type": "noul", "instructions": instructions}+ assert _post(client, questions = {"urgent": question}).status_code == 200+ assert any("これは緊急ですか" in text for text in word_laya.tok.texts)++@pytest.mark.parametrize("words, cut", [(900, False), (901, True), (5000, True)])def test_state_cut_matches_the_full_tokenization(words, cut):pytest.importorskip("torch")diff --git a/tests/test_decision_model.py b/tests/test_decision_model.pyindex 763cdad2614..ded9c396e5a 100644--- a/tests/test_decision_model.py+++ b/tests/test_decision_model.py@@ -1453,6 +1453,11 @@ def test_a_failed_save_leaves_the_previous_clef_checkpoint_loadable(FastDecisionModel.from_pretrained(str(out), max_seq_length = 512)+def test_structured_instructions_train_as_written():+ question = {"type": "noul", "instructions": {"ask": "これは緊急ですか"}}+ assert "これは緊急ですか" in _decision_common._internal(question)["ins"]++def test_kl_regularization_needs_a_lora_clef(clef_checkpoint, tmp_path):model, processor = FastDecisionModel.from_pretrained(str(clef_checkpoint), max_seq_length = 512, full_finetuning = Truediff --git a/unsloth/models/_decision_common.py b/unsloth/models/_decision_common.pyindex e3826f909b5..0ecb7f28b99 100644--- a/unsloth/models/_decision_common.py+++ b/unsloth/models/_decision_common.py@@ -276,10 +276,11 @@ def _internal(question, name = "") -> dict:if kind == "noul" and criteria is not None and not isinstance(criteria, dict):raise DecisionDataError('criteria may only have "true" and "false"')instructions = question.get("instructions")- laya_question = {- "type": kind,- "instructions": str(name) if instructions in (None, "") else instructions,- }+ if instructions in (None, ""):+ instructions = str(name)+ elif not isinstance(instructions, str):+ instructions = json.dumps(instructions, ensure_ascii = False)+ laya_question = {"type": kind, "instructions": instructions}if criteria is not None:laya_question["criteria"] = criteriareturn _laya().agent.Agent._to_internal(laya_question)