Skip to content

Commit 497bd94

Browse files
sayanshaw24Sayan Shawbaijumeswani
authored
Default add_generation_prompt for Chat Templates to true in Python API (microsoft#1539)
Adds default to make `add_generation_prompt` optional in the Python API (note: because of lack of support for optionals in the C API we can only do this for Python). --------- Co-authored-by: Sayan Shaw <[email protected]> Co-authored-by: Baiju Meswani <[email protected]>
1 parent 49d9f76 commit 497bd94

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/python/python.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ PYBIND11_MODULE(onnxruntime_genai, m) {
358358
})
359359
.def("to_token_id", &OgaTokenizer::ToTokenId)
360360
.def("decode", [](const OgaTokenizer& t, pybind11::array_t<int32_t> tokens) -> std::string { return t.Decode(ToSpan(tokens)).p_; })
361-
.def("apply_chat_template", [](const OgaTokenizer& t, const char* template_str, const char* messages, const char* tools, bool add_generation_prompt) -> std::string { return t.ApplyChatTemplate(template_str, messages, tools, add_generation_prompt).p_; }, pybind11::arg("template_str") = nullptr, pybind11::arg("messages"), pybind11::arg("tools") = nullptr, pybind11::arg("add_generation_prompt"))
361+
.def("apply_chat_template", [](const OgaTokenizer& t, const char* messages, const char* template_str, const char* tools, bool add_generation_prompt) -> std::string { return t.ApplyChatTemplate(template_str, messages, tools, add_generation_prompt).p_; }, pybind11::arg("messages"), pybind11::kw_only(), pybind11::arg("template_str") = nullptr, pybind11::arg("tools") = nullptr, pybind11::arg("add_generation_prompt") = true)
362362
.def("encode_batch", [](const OgaTokenizer& t, std::vector<std::string> strings) {
363363
std::vector<const char*> c_strings;
364364
for (const auto& s : strings)

0 commit comments

Comments
 (0)