File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 99#include " common.h"
1010#include " chat-template.hpp"
1111
12+ static std::string normalize_newlines (const std::string & s) {
13+ #ifdef _WIN32
14+ static const std::regex nl_regex (" \r\n " );
15+ return std::regex_replace (s, nl_regex, " \n " );
16+ #else
17+ return s;
18+ #endif
19+ }
20+
1221int main (void ) {
1322 std::vector<llama_chat_message> conversation {
1423 {" system" , " You are a helpful assistant" },
@@ -300,8 +309,8 @@ int main(void) {
300309 printf (" \n\n === %s (jinja) ===\n\n " , test_case.name .c_str ());
301310 try {
302311 minja::chat_template tmpl (test_case.template_str , test_case.bos_token , test_case.eos_token );
303- auto output = tmpl.apply (messages, json (), add_generation_prompt);
304- auto expected_output = test_case.expected_output_jinja .empty () ? test_case.expected_output : test_case.expected_output_jinja ;
312+ auto output = normalize_newlines ( tmpl.apply (messages, json (), add_generation_prompt) );
313+ auto expected_output = normalize_newlines ( test_case.expected_output_jinja .empty () ? test_case.expected_output : test_case.expected_output_jinja ) ;
305314 if (output != expected_output) {
306315 printf (" Expected:\n %s\n " , expected_output.c_str ());
307316 printf (" -------------------------\n " );
You can’t perform that action at this time.
0 commit comments