Skip to content

Commit f9ed84a

Browse files
committed
fix(cpp): correct validateModelChatTemplate fn
1 parent 488483c commit f9ed84a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cpp/rn-llama.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,11 @@ struct llama_rn_context
232232
bool validateModelChatTemplate() const {
233233
llama_chat_message chat[] = {{"user", "test"}};
234234

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

237-
return res > 0;
239+
return res >= 0;
238240
}
239241

240242
void truncatePrompt(std::vector<llama_token> &prompt_tokens) {

0 commit comments

Comments
 (0)