Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/llama-chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,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 {
Expand Down