Use intermediate vector for string assignment
This commit is contained in:
parent
ada3cbf8c5
commit
dff9b2e105
1 changed files with 4 additions and 2 deletions
|
@ -2970,8 +2970,10 @@ int main(int argc, char ** argv) {
|
|||
std::string template_key = "tokenizer.chat_template", curr_tmpl;
|
||||
int32_t tlen = llama_model_meta_val_str(ctx_server.model, template_key.c_str(), nullptr, 0);
|
||||
if (tlen > 0) {
|
||||
curr_tmpl.resize(tlen + 1);
|
||||
llama_model_meta_val_str(ctx_server.model, template_key.c_str(), &curr_tmpl[0], curr_tmpl.size());
|
||||
std::vector<char> curr_tmpl_buf(tlen + 1, 0);
|
||||
if (llama_model_meta_val_str(ctx_server.model, template_key.c_str(), curr_tmpl_buf.data(), curr_tmpl_buf.size()) == tlen) {
|
||||
curr_tmpl = std::string(curr_tmpl_buf.data(), tlen);
|
||||
}
|
||||
}
|
||||
res.set_header("Access-Control-Allow-Origin", req.get_header_value("Origin"));
|
||||
json data = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue