Fix for simple-chat
This commit is contained in:
parent
dbe531ea9f
commit
b3e343eae7
1 changed files with 3 additions and 3 deletions
|
@ -158,10 +158,10 @@ int main(int argc, char ** argv) {
|
||||||
|
|
||||||
// add the user input to the message list and format it
|
// add the user input to the message list and format it
|
||||||
messages.push_back({"user", strdup(user.c_str())});
|
messages.push_back({"user", strdup(user.c_str())});
|
||||||
int new_len = llama_chat_apply_template(model, nullptr, messages.data(), messages.size(), true, formatted.data(), formatted.size());
|
int new_len = llama_chat_apply_template(model, nullptr, nullptr, nullptr, messages.data(), messages.size(), true, formatted.data(), formatted.size());
|
||||||
if (new_len > (int)formatted.size()) {
|
if (new_len > (int)formatted.size()) {
|
||||||
formatted.resize(new_len);
|
formatted.resize(new_len);
|
||||||
new_len = llama_chat_apply_template(model, nullptr, messages.data(), messages.size(), true, formatted.data(), formatted.size());
|
new_len = llama_chat_apply_template(model, nullptr, nullptr, nullptr, messages.data(), messages.size(), true, formatted.data(), formatted.size());
|
||||||
}
|
}
|
||||||
if (new_len < 0) {
|
if (new_len < 0) {
|
||||||
fprintf(stderr, "failed to apply the chat template\n");
|
fprintf(stderr, "failed to apply the chat template\n");
|
||||||
|
@ -178,7 +178,7 @@ int main(int argc, char ** argv) {
|
||||||
|
|
||||||
// add the response to the messages
|
// add the response to the messages
|
||||||
messages.push_back({"assistant", strdup(response.c_str())});
|
messages.push_back({"assistant", strdup(response.c_str())});
|
||||||
prev_len = llama_chat_apply_template(model, nullptr, messages.data(), messages.size(), false, nullptr, 0);
|
prev_len = llama_chat_apply_template(model, nullptr, nullptr, nullptr, messages.data(), messages.size(), false, nullptr, 0);
|
||||||
if (prev_len < 0) {
|
if (prev_len < 0) {
|
||||||
fprintf(stderr, "failed to apply the chat template\n");
|
fprintf(stderr, "failed to apply the chat template\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue