This commit is contained in:
AnonN10 2026-02-06 20:46:37 +01:00 committed by GitHub
commit 54f7fc8a98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 5 deletions

View File

@ -79,14 +79,15 @@ static const std::map<std::string, llm_chat_template> LLM_CHAT_TEMPLATES = {
};
llm_chat_template llm_chat_template_from_str(const std::string & name) {
return LLM_CHAT_TEMPLATES.at(name);
if (auto it = LLM_CHAT_TEMPLATES.find(name); it != LLM_CHAT_TEMPLATES.end()) {
return it->second;
}
return LLM_CHAT_TEMPLATE_UNKNOWN;
}
llm_chat_template llm_chat_detect_template(const std::string & tmpl) {
try {
return llm_chat_template_from_str(tmpl);
} catch (const std::out_of_range &) {
// ignore
if (auto t = llm_chat_template_from_str(tmpl); t != LLM_CHAT_TEMPLATE_UNKNOWN) {
return t;
}
auto tmpl_contains = [&tmpl](const char * haystack) -> bool {