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>
This commit is contained in:
Tenith Hasintha 2026-05-14 20:19:47 +05:30 committed by GitHub
commit 739ebeea82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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