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
fix: system prompt ignored in unsloth inference (#4528)
Wasim Yousef Saidc8057d911b34
diff --git a/studio/backend/core/inference/inference.py b/studio/backend/core/inference/inference.pyindex 6cb077f4a93..1a265690ff0 100644--- a/studio/backend/core/inference/inference.py+++ b/studio/backend/core/inference/inference.py@@ -927,6 +927,12 @@ class InferenceBackend:logger.warning(f"Could not apply get_chat_template: {e}")# Step 2: Format with tokenizer.apply_chat_template()+ if system_prompt:+ template_messages = [+ {"role": "system", "content": system_prompt}+ ] + messages+ else:+ template_messages = messagestry:if not (hasattr(tokenizer, "chat_template") and tokenizer.chat_template):raise ValueError(@@ -937,7 +943,7 @@ class InferenceBackend:f"one via tokenizer.chat_template before inference.")formatted_prompt = tokenizer.apply_chat_template(- messages, tokenize = False, add_generation_prompt = True+ template_messages, tokenize = False, add_generation_prompt = True)logger.debug(f"Formatted prompt: {formatted_prompt[:200]}...")except Exception as e:@@ -992,19 +998,40 @@ class InferenceBackend:# Prepare vision messagesif image:- vision_messages = [- {- "role": "user",- "content": [- {"type": "image"},- {"type": "text", "text": user_message},- ],- }- ]-- input_text = processor.apply_chat_template(- vision_messages, add_generation_prompt = True, tokenize = False- )+ user_msg = {+ "role": "user",+ "content": [+ {"type": "image"},+ {"type": "text", "text": user_message},+ ],+ }+ if system_prompt:+ vision_messages = [+ {+ "role": "system",+ "content": [{"type": "text", "text": system_prompt}],+ },+ user_msg,+ ]+ else:+ vision_messages = [user_msg]++ try:+ input_text = processor.apply_chat_template(+ vision_messages, add_generation_prompt = True, tokenize = False+ )+ except Exception as e:+ if system_prompt:+ logger.warning(+ f"Vision processor for '{self.active_model_name}' may not support "+ f"system messages; retrying without. Original error: {e}"+ )+ vision_messages = [user_msg]+ input_text = processor.apply_chat_template(+ vision_messages, add_generation_prompt = True, tokenize = False+ )+ else:+ raiseinputs = processor(image,input_text,