MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / parse_prefixed_json_tool_call_array

Function parse_prefixed_json_tool_call_array

smallthinker/common/chat.cpp:698–709  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

696}
697
698static void parse_prefixed_json_tool_call_array(common_chat_msg_parser & builder, const common_regex & prefix, size_t rstrip_prefix = 0) {
699 static const std::vector<std::vector<std::string>> args_paths = {{"arguments"}};
700 if (auto res = builder.try_find_regex(prefix)) {
701 builder.move_back(rstrip_prefix);
702 auto tool_calls = builder.consume_json_with_dumped_args(args_paths);
703 if (!builder.add_tool_calls(tool_calls.value) || tool_calls.is_partial) {
704 throw common_chat_msg_partial_exception("incomplete tool call array");
705 }
706 } else {
707 builder.add_content(builder.consume_rest());
708 }
709}
710
711static void foreach_function(const json & tools, const std::function<void(const json &)> & fn) {
712 for (const auto & tool : tools) {

Calls 7

try_find_regexMethod · 0.80
move_backMethod · 0.80
add_tool_callsMethod · 0.80
add_contentMethod · 0.80
consume_restMethod · 0.80

Tested by

no test coverage detected