make output a bit cleaner

This commit is contained in:
Xuan Son Nguyen 2026-01-01 23:07:45 +01:00
parent b23b5e3c01
commit a66e4a4f5d
2 changed files with 13 additions and 2 deletions

View File

@ -574,6 +574,16 @@ struct vm {
value_string gather_string_parts(const value & val) {
value_string parts = mk_val<value_string>();
gather_string_parts_recursive(val, parts);
// join consecutive parts with the same type
auto & p = parts->val_str.parts;
for (size_t i = 1; i < p.size(); ) {
if (p[i].is_input == p[i - 1].is_input) {
p[i - 1].val += p[i].val;
p.erase(p.begin() + i);
} else {
i++;
}
}
return parts;
}
};

View File

@ -56,7 +56,8 @@ std::string DEFAULT_JSON = R"({
],
"bos_token": "<s>",
"eos_token": "</s>",
"tools": []
"tools": [],
"add_generation_prompt": true
})";
int main(int argc, char ** argv) {
@ -181,7 +182,7 @@ void run_single(std::string contents, json input) {
auto parts = vm.gather_string_parts(results);
std::cout << "\n=== RESULTS ===\n";
for (const auto & part : parts.get()->val_str.parts) {
for (const auto & part : parts->as_string().parts) {
std::cout << (part.is_input ? "DATA" : "TMPL") << ": " << part.val << "\n";
}
}