| 508 | } |
| 509 | |
| 510 | std::string common_chat_format_example(const struct common_chat_templates * tmpls, |
| 511 | bool use_jinja, |
| 512 | const std::map<std::string, std::string> & chat_template_kwargs) { |
| 513 | common_chat_templates_inputs inputs; |
| 514 | inputs.use_jinja = use_jinja; |
| 515 | inputs.add_bos = tmpls->add_bos; |
| 516 | inputs.add_eos = tmpls->add_eos; |
| 517 | inputs.chat_template_kwargs = chat_template_kwargs; |
| 518 | auto add_simple_msg = [&](auto role, auto content) { |
| 519 | common_chat_msg msg; |
| 520 | msg.role = role; |
| 521 | msg.content = content; |
| 522 | inputs.messages.push_back(msg); |
| 523 | }; |
| 524 | add_simple_msg("system", "You are a helpful assistant"); |
| 525 | add_simple_msg("user", "Hello"); |
| 526 | add_simple_msg("assistant", "Hi there"); |
| 527 | add_simple_msg("user", "How are you?"); |
| 528 | return common_chat_templates_apply(tmpls, inputs).prompt; |
| 529 | } |
| 530 | |
| 531 | #define CHATML_TEMPLATE_SRC \ |
| 532 | "{%- for message in messages -%}\n" \ |
no test coverage detected