Skip to content

Commit 5cd0000

Browse files
committed
server : fix validate_model_chat_template
1 parent 54ef9cf commit 5cd0000

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

examples/server/server.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,11 @@ struct server_context {
657657
bool validate_model_chat_template() const {
658658
llama_chat_message chat[] = {{"user", "test"}};
659659

660-
const int res = llama_chat_apply_template(model, nullptr, chat, 1, true, nullptr, 0);
660+
std::vector<char> model_template(2048, 0); // longest known template is about 1200 bytes
661+
std::string template_key = "tokenizer.chat_template";
662+
int32_t res = llama_model_meta_val_str(model, template_key.c_str(), model_template.data(), model_template.size());
661663

662-
return res > 0;
664+
return res >= 0;
663665
}
664666

665667
void init() {

0 commit comments

Comments
 (0)