From 739ebeea8241d125c1bb8fa401207e62dcacb326 Mon Sep 17 00:00:00 2001 From: Tenith Hasintha <102300949+Tenith01@users.noreply.github.com> Date: Thu, 14 May 2026 20:19:47 +0530 Subject: [PATCH] Fix/issue 3667 vicuna template (#5357) * Fix: Add missing utf-8 encoding to text-mode file operations Fixes #2795 by explicitly adding encoding='utf-8' to open() calls. This prevents UnicodeDecodeError on Windows with non-UTF-8 system locales when processing files containing UTF-8 characters. * fix(chat_templates): escape apostrophe in vicuna default system message The unescaped apostrophe in 'user's' broke Jinja2 template parsing when _change_system_message() substituted the default message into the template string via re.sub. Escape it with \' to match the existing vicuna_old pattern. Fixes #3667 --------- Co-authored-by: Roland Tannous <115670425+rolandtannous@users.noreply.github.com> --- unsloth/chat_templates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unsloth/chat_templates.py b/unsloth/chat_templates.py index 1c94e10f9f..e8a34cbc60 100644 --- a/unsloth/chat_templates.py +++ b/unsloth/chat_templates.py @@ -211,7 +211,7 @@ vicuna_ollama = _ollama_template("vicuna") vicuna_eos_token = "eos_token" CHAT_TEMPLATES["vicuna"] = (vicuna_template, vicuna_eos_token, False, vicuna_ollama,) -DEFAULT_SYSTEM_MESSAGE["vicuna"] = "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions." +DEFAULT_SYSTEM_MESSAGE["vicuna"] = "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user\\'s questions." # =========================================== Vicuna Old # https://github.com/lm-sys/FastChat/blob/main/docs/vicuna_weights_version.md#prompt-template