File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -528,12 +528,17 @@ int32_t llm_chat_apply_template(
528
528
}
529
529
} else if (tmpl == LLM_CHAT_TEMPLATE_RWKV_WORLD) {
530
530
// this template requires the model to have "\n\n" as EOT token
531
- for (auto message : chat) {
532
- std::string role (message->role );
533
- if (role == " user" ) {
534
- ss << " User: " << message->content << " \n\n Assistant:" ;
535
- } else {
536
- ss << message->content << " \n\n " ;
531
+ for (size_t i = 0 ; i < chat.size (); i++) {
532
+ std::string role (chat[i]->role );
533
+ if (role == " system" ) {
534
+ ss << " System: " << trim (chat[i]->content ) << " \n\n " ;
535
+ } else if (role == " user" ) {
536
+ ss << " User: " << trim (chat[i]->content ) << " \n\n " ;
537
+ if (i == chat.size () - 1 ) {
538
+ ss << " Assistant:" ;
539
+ }
540
+ } else if (role == " assistant" ) {
541
+ ss << " Assistant: " << trim (chat[i]->content ) << " \n\n " ;
537
542
}
538
543
}
539
544
} else if (tmpl == LLM_CHAT_TEMPLATE_GRANITE) {
Original file line number Diff line number Diff line change @@ -292,6 +292,7 @@ int main(int argc, char ** argv) {
292
292
293
293
if (!params.system_prompt .empty () || !params.prompt .empty ()) {
294
294
common_chat_templates_inputs inputs;
295
+ inputs.use_jinja = g_params->use_jinja ;
295
296
inputs.messages = chat_msgs;
296
297
inputs.add_generation_prompt = !params.prompt .empty ();
297
298
You can’t perform that action at this time.
0 commit comments