minja
: try to please gcc
This commit is contained in:
parent
94377d743c
commit
059babdd9b
2 changed files with 33 additions and 33 deletions
|
@ -376,38 +376,6 @@ public:
|
|||
throw std::runtime_error("get<T> not defined for this value type: " + dump());
|
||||
}
|
||||
|
||||
template <>
|
||||
json get<json>() const {
|
||||
if (is_primitive()) return primitive_;
|
||||
if (is_null()) return json();
|
||||
if (array_) {
|
||||
std::vector<json> res;
|
||||
for (const auto& item : *array_) {
|
||||
res.push_back(item.get<json>());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
if (object_) {
|
||||
json res = json::object();
|
||||
for (const auto& item : *object_) {
|
||||
const auto & key = item.first;
|
||||
auto json_value = item.second.get<json>();
|
||||
if (key.is_string()) {
|
||||
res[key.get<std::string>()] = json_value;
|
||||
} else if (key.is_primitive()) {
|
||||
res[key.dump()] = json_value;
|
||||
} else {
|
||||
throw std::runtime_error("Invalid key type for conversion to JSON: " + key.dump());
|
||||
}
|
||||
}
|
||||
if (is_callable()) {
|
||||
res["__callable__"] = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
throw std::runtime_error("get<json> not defined for this value type: " + dump());
|
||||
}
|
||||
|
||||
std::string dump(int indent=-1, bool to_json=false) const {
|
||||
std::ostringstream out;
|
||||
dump(out, indent, 0, to_json ? '"' : '\'');
|
||||
|
@ -466,6 +434,38 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
json Value::get<json>() const {
|
||||
if (is_primitive()) return primitive_;
|
||||
if (is_null()) return json();
|
||||
if (array_) {
|
||||
std::vector<json> res;
|
||||
for (const auto& item : *array_) {
|
||||
res.push_back(item.get<json>());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
if (object_) {
|
||||
json res = json::object();
|
||||
for (const auto& item : *object_) {
|
||||
const auto & key = item.first;
|
||||
auto json_value = item.second.get<json>();
|
||||
if (key.is_string()) {
|
||||
res[key.get<std::string>()] = json_value;
|
||||
} else if (key.is_primitive()) {
|
||||
res[key.dump()] = json_value;
|
||||
} else {
|
||||
throw std::runtime_error("Invalid key type for conversion to JSON: " + key.dump());
|
||||
}
|
||||
}
|
||||
if (is_callable()) {
|
||||
res["__callable__"] = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
throw std::runtime_error("get<json> not defined for this value type: " + dump());
|
||||
}
|
||||
|
||||
} // namespace minja
|
||||
|
||||
namespace std {
|
||||
|
|
|
@ -21081,8 +21081,8 @@ static int32_t llama_chat_apply_template_internal(
|
|||
context->set("tools", tools_val);
|
||||
}
|
||||
auto tmpl_root = minja::Parser::parse(tmpl, {
|
||||
.lstrip_blocks = true,
|
||||
.trim_blocks = true,
|
||||
.lstrip_blocks = true,
|
||||
});
|
||||
try {
|
||||
dest = tmpl_root->render(context);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue