Skip to content

Commit 103c840

Browse files
author
ochafik
committed
fix content part string concat in legacy template branch
1 parent a58e1fc commit 103c840

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

common/chat.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,8 +1448,12 @@ common_chat_params common_chat_templates_apply(
14481448
content += part.text;
14491449
}
14501450
contents.emplace_back(std::move(content));
1451-
chat.push_back({msg.role.c_str(), contents.back().c_str()});
1452-
alloc_size += (msg.role.size() + contents.back().size()) * 1.25;
1451+
}
1452+
for (size_t i = 0; i < contents.size(); ++i) {
1453+
const auto & msg = inputs.messages[i];
1454+
const auto & content = contents[i];
1455+
chat.push_back({msg.role.c_str(), content.c_str()});
1456+
alloc_size += (msg.role.size() + content.size()) * 1.25;
14531457
}
14541458

14551459
std::vector<char> buf(alloc_size);

0 commit comments

Comments
 (0)