From cc503564702917992e101a9c79f15335dac1a5b0 Mon Sep 17 00:00:00 2001 From: ochafik Date: Sat, 18 Jan 2025 17:55:04 +0000 Subject: [PATCH] minja: fix vigogne (https://github.com/google/minja/pull/22) --- common/minja.hpp | 10 ++++------ tests/test-chat-template.cpp | 1 - 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/common/minja.hpp b/common/minja.hpp index 2639c15a0c738..c1c4212c74a16 100644 --- a/common/minja.hpp +++ b/common/minja.hpp @@ -1305,12 +1305,10 @@ struct ArgumentsExpression { }; static std::string strip(const std::string & s) { - static std::regex trailing_spaces_regex("^\\s+|\\s+$"); - return std::regex_replace(s, trailing_spaces_regex, ""); - // auto start = s.find_first_not_of(" \t\n\r"); - // if (start == std::string::npos) return ""; - // auto end = s.find_last_not_of(" \t\n\r"); - // return s.substr(start, end - start + 1); + auto start = s.find_first_not_of(" \t\n\r"); + if (start == std::string::npos) return ""; + auto end = s.find_last_not_of(" \t\n\r"); + return s.substr(start, end - start + 1); } static std::string html_escape(const std::string & s) { diff --git a/tests/test-chat-template.cpp b/tests/test-chat-template.cpp index 6b877f65901e3..1906431362e9b 100644 --- a/tests/test-chat-template.cpp +++ b/tests/test-chat-template.cpp @@ -68,7 +68,6 @@ int main(void) { /* .expected_output_jinja= */ "[INST] <>\nYou are a helpful assistant\n<>\n\nHello [/INST] Hi there [INST] Who are you [/INST] I am an assistant [INST] Another question [/INST]", /* .bos_token= */ "", /* .eos_token= */ "", - /* .supported_with_jinja= */ false, // Mysteriously fails on windows-latest in llama.cpp's CI, although that template works fine in Minja's CI on windows-latest }, { /* .name= */ "mlabonne/AlphaMonarch-7B",