mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-09-17 20:31:47 +02:00
cont : cleanup
This commit is contained in:
@@ -384,7 +384,11 @@ common_peg_parser analyze_tools::build_tool_parser_tag_tagged(parser_build_conte
|
||||
p.tool_arg_close(p.literal(arguments.value_suffix)))));
|
||||
|
||||
auto named_arg = p.rule("tool-" + name + "-arg-" + param.name, arg);
|
||||
(param.required ? required_parsers : optional_parsers).push_back(named_arg);
|
||||
if (param.required) {
|
||||
required_parsers.push_back(named_arg);
|
||||
} else {
|
||||
optional_parsers.push_back(named_arg);
|
||||
}
|
||||
});
|
||||
|
||||
// Build required arg sequence in definition order
|
||||
|
||||
@@ -165,7 +165,11 @@ common_chat_params common_chat_params_init_deepseek_v3_2(const common_chat_templ
|
||||
p.tool_arg_close(p.literal(PARAM_END)));
|
||||
|
||||
auto named_arg = p.rule("tool-" + name + "-arg-" + param.name, arg);
|
||||
(param.required ? required_parsers : optional_parsers).push_back(named_arg);
|
||||
if (param.required) {
|
||||
required_parsers.push_back(named_arg);
|
||||
} else {
|
||||
optional_parsers.push_back(named_arg);
|
||||
}
|
||||
});
|
||||
|
||||
common_peg_parser args_seq = p.eps();
|
||||
|
||||
@@ -88,7 +88,8 @@ common_chat_params common_chat_params_init_minimax_m3(const common_chat_template
|
||||
foreach_function(inputs.tools, [&](const json & tool) {
|
||||
const auto & function = tool.at("function");
|
||||
std::string name = function.at("name");
|
||||
auto doc = parse_parameters(function);
|
||||
auto params = function.contains("parameters") ? function.at("parameters") : json::object();
|
||||
auto doc = std::make_shared<const common_schema_document>(common_schema_parse(params));
|
||||
|
||||
// The template expands argument values recursively in XML (see the to_xml() macro)
|
||||
std::function<common_peg_parser(const common_schema &, const std::string &, const std::string &)> value_of;
|
||||
|
||||
@@ -12,13 +12,9 @@ void foreach_function(const json & tools, const std::function<void(const json &)
|
||||
}
|
||||
}
|
||||
|
||||
common_schema_document_ptr parse_parameters(const json & function) {
|
||||
auto params = function.contains("parameters") ? function.at("parameters") : json::object();
|
||||
return std::make_shared<const common_schema_document>(common_schema_parse(params));
|
||||
}
|
||||
|
||||
void foreach_parameter(const json & function, const std::function<void(const common_schema_property &, const common_schema_document_ptr &)> & fn) {
|
||||
auto doc = parse_parameters(function);
|
||||
auto params = function.contains("parameters") ? function.at("parameters") : json::object();
|
||||
auto doc = std::make_shared<const common_schema_document>(common_schema_parse(params));
|
||||
const auto * object = dynamic_cast<const common_schema_object *>(doc->root.get());
|
||||
if (!object) {
|
||||
return;
|
||||
|
||||
@@ -20,9 +20,6 @@ using json = common_json;
|
||||
// iterate over the function tools of an OpenAI-style tools array
|
||||
void foreach_function(const json & tools, const std::function<void(const json &)> & fn);
|
||||
|
||||
// the parsed parameters schema of a function tool, an any when it has none
|
||||
common_schema_document_ptr parse_parameters(const json & function);
|
||||
|
||||
// iterate over the parameters of a function tool, with the document that owns them
|
||||
void foreach_parameter(const json & function, const std::function<void(const common_schema_property &, const common_schema_document_ptr &)> & fn);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user