Skip to content

Commit 8a44b2f

Browse files
author
Olivier Chafik
committed
Fix empty content for functionary v3.2 tool call
1 parent 422df5d commit 8a44b2f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

common/chat.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,17 @@ static common_chat_msg common_chat_parse_functionary_v3_2(const std::string & in
591591
}
592592
}
593593
// TODO: tighten & simplify.
594-
auto res = parse_json_tool_calls(std::string(it, end), std::nullopt, function_regex, close_regex);
595-
res.content = content;
596-
return res;
594+
try {
595+
auto res = parse_json_tool_calls(std::string(it, end), std::nullopt, function_regex, close_regex);
596+
res.content = content + res.content;
597+
return res;
598+
} catch (const std::exception & e) {
599+
LOG_ERR("Failed to parse functionary v3.2 input: %s", e.what());
600+
common_chat_msg res;
601+
res.role = "assistant";
602+
res.content = input;
603+
return res;
604+
}
597605
}
598606

599607
static common_chat_params common_chat_params_init_functionary_v3_1_llama_3_1(const common_chat_template & tmpl, const struct common_chat_inputs & inputs) {

0 commit comments

Comments
 (0)