@@ -64,6 +64,7 @@ static const std::map<std::string, llm_chat_template> LLM_CHAT_TEMPLATES = {
6464 { " bailing" , LLM_CHAT_TEMPLATE_BAILING },
6565 { " llama4" , LLM_CHAT_TEMPLATE_LLAMA4 },
6666 { " smolvlm" , LLM_CHAT_TEMPLATE_SMOLVLM },
67+ { " seed-coder" , LLM_CHAT_TEMPLATE_SEED_CODER },
6768};
6869
6970llm_chat_template llm_chat_template_from_str (const std::string & name) {
@@ -183,6 +184,9 @@ llm_chat_template llm_chat_detect_template(const std::string & tmpl) {
183184 return LLM_CHAT_TEMPLATE_BAILING;
184185 } else if (tmpl_contains (" <|header_start|>" ) && tmpl_contains (" <|header_end|>" )) {
185186 return LLM_CHAT_TEMPLATE_LLAMA4;
187+ } else if (tmpl_contains (" raise_exception" ) && tmpl_contains (" System role not supported" ) &&
188+ tmpl_contains (" Conversation roles must alternate user/assistant/user/assistant/..." )) {
189+ return LLM_CHAT_TEMPLATE_SEED_CODER;
186190 }
187191 return LLM_CHAT_TEMPLATE_UNKNOWN;
188192}
@@ -643,6 +647,17 @@ int32_t llm_chat_apply_template(
643647 if (add_ass) {
644648 ss << " Assistant:" ;
645649 }
650+ } else if (tmpl == LLM_CHAT_TEMPLATE_SEED_CODER) {
651+ // Seed-Coder
652+ for (auto message : chat) {
653+ std::string role (message->role );
654+ if (role == " user" ) {
655+ ss << " <[begin▁of▁sentence]>" << role << " \n " << trim (message->content ) << " <[end▁of▁sentence]>" ;
656+ }
657+ }
658+ if (add_ass) {
659+ ss << " <[begin▁of▁sentence]>assistant\n " ;
660+ }
646661 } else {
647662 // template not supported
648663 return -1 ;
0 commit comments