Merge b8aec23086
into 77e15bec62
This commit is contained in:
commit
bd7a95e799
2 changed files with 41 additions and 1 deletions
|
@ -382,6 +382,10 @@ static json oaicompat_completion_params_parse(
|
|||
llama_params["stop"] = json_value(body, "stop", json::array());
|
||||
}
|
||||
|
||||
if( chat_template.find("minicpm") != std::string::npos){
|
||||
llama_params["stop"].insert(llama_params["stop"].end(), {"<|im_end|>", "</s>"});
|
||||
}
|
||||
|
||||
// Handle "response_format" field
|
||||
if (body.contains("response_format")) {
|
||||
json response_format = json_value(body, "response_format", json::object());
|
||||
|
|
36
llama.cpp
36
llama.cpp
|
@ -17749,6 +17749,42 @@ static int32_t llama_chat_apply_template_internal(
|
|||
if (add_ass) {
|
||||
ss << "<|assistant|>\n";
|
||||
}
|
||||
} else if (tmpl == "minicpm" || (tmpl.find("<用户>") != std::string::npos && tmpl.find("<AI>") != std::string::npos )) {
|
||||
|
||||
for (auto message : chat) {
|
||||
std::string role(message->role);
|
||||
if (role == "user"){
|
||||
ss << "<用户>: " << trim(message->content) << "\n";
|
||||
}else{
|
||||
ss << "<AI>: " << trim(message->content) << "\n";
|
||||
}
|
||||
}
|
||||
if (add_ass) {
|
||||
ss << "\n<AI>: ";
|
||||
}
|
||||
}else if (tmpl == "minicpm-128k" || tmpl.find("<|im_start|>") != std::string::npos) {
|
||||
// chatml template
|
||||
std::string tmp = "";
|
||||
for (auto message : chat) {
|
||||
std::string role(message->role);
|
||||
std::string content(message->content);
|
||||
//remove system ...
|
||||
if (message->role == "system"){
|
||||
role = "user";
|
||||
tmp = message->content;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(role == "user" && tmp !=""){
|
||||
content =tmp+"\n\n"+ message->content;
|
||||
tmp = "";
|
||||
}
|
||||
|
||||
ss << "<|im_start|>" << role << "\n" << content << "<|im_end|>\n";
|
||||
}
|
||||
if (add_ass) {
|
||||
ss << "<|im_start|>assistant\n";
|
||||
}
|
||||
}else {
|
||||
// template not supported
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue