| 227 | |
| 228 | |
| 229 | static std::string format_using_common( |
| 230 | const std::string & template_str, |
| 231 | const std::string & bos_token, |
| 232 | const std::string & eos_token, |
| 233 | std::vector<common_chat_msg> & messages, |
| 234 | std::vector<common_chat_tool> tools = {}) { |
| 235 | auto tmpls = common_chat_templates_init(/* model= */ nullptr, template_str, bos_token, eos_token); |
| 236 | common_chat_templates_inputs inputs; |
| 237 | inputs.use_jinja = true; |
| 238 | inputs.messages = messages; |
| 239 | inputs.tools = std::move(tools); |
| 240 | inputs.add_generation_prompt = true; |
| 241 | auto output = common_chat_templates_apply(tmpls.get(), inputs).prompt; |
| 242 | output = normalize_newlines(output); |
| 243 | return output; |
| 244 | } |
| 245 | |
| 246 | |
| 247 | // skip libcommon, use direct jinja engine |
no test coverage detected