mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-11-15 07:19:53 +00:00
server : fix incorrect res in validate_model_chat_template (#10272)
* server : fix validate_model_chat_template * server : fix chat res
This commit is contained in:
parent
a0ec17b32e
commit
0e712a5acb
@ -655,11 +655,16 @@ struct server_context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool validate_model_chat_template() const {
|
bool validate_model_chat_template() const {
|
||||||
|
std::vector<char> model_template(2048, 0); // longest known template is about 1200 bytes
|
||||||
|
std::string template_key = "tokenizer.chat_template";
|
||||||
|
int32_t res = llama_model_meta_val_str(model, template_key.c_str(), model_template.data(), model_template.size());
|
||||||
|
if (res >= 0) {
|
||||||
llama_chat_message chat[] = {{"user", "test"}};
|
llama_chat_message chat[] = {{"user", "test"}};
|
||||||
|
std::string tmpl = std::string(model_template.data(), model_template.size());
|
||||||
const int res = llama_chat_apply_template(model, nullptr, chat, 1, true, nullptr, 0);
|
int32_t chat_res = llama_chat_apply_template(model, tmpl.c_str(), chat, 1, true, nullptr, 0);
|
||||||
|
return chat_res > 0;
|
||||||
return res > 0;
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
|
Loading…
Reference in New Issue
Block a user