add some workarounds
This commit is contained in:
parent
e858b7a0a3
commit
9b79863da3
|
|
@ -154,6 +154,28 @@ static void caps_apply_workarounds(context & ctx, const caps & c) {
|
|||
}
|
||||
|
||||
ctx.set_val("messages", messages);
|
||||
|
||||
//
|
||||
// per-model workarounds
|
||||
//
|
||||
|
||||
// workaround for shieldgemma-2b-Q2_K
|
||||
if (ctx.get_val("guideline")->is_undefined()) {
|
||||
ctx.set_val("guideline", mk_val<value_string>(""));
|
||||
}
|
||||
|
||||
// workaround for functionary models
|
||||
if (ctx.get_val("functions")->is_undefined()) {
|
||||
ctx.set_val("functions", mk_val<value_string>(""));
|
||||
}
|
||||
if (ctx.get_val("datetime")->is_undefined()) {
|
||||
ctx.set_val("datetime", mk_val<value_string>(""));
|
||||
}
|
||||
|
||||
// workaround for Llama-3-5B-Sheard
|
||||
if (ctx.get_val("system_message")->is_undefined()) {
|
||||
ctx.set_val("system_message", mk_val<value_string>(""));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace jinja
|
||||
|
|
|
|||
|
|
@ -216,6 +216,12 @@ private:
|
|||
expect(token::close_statement, "Expected %}");
|
||||
result = mk_stmt<filter_statement>(std::move(filter_node), std::move(body));
|
||||
|
||||
} else if (name == "generation" || name == "endgeneration") {
|
||||
// Ignore generation blocks (transformers-specific)
|
||||
// See https://github.com/huggingface/transformers/pull/30650 for more information.
|
||||
result = mk_stmt<noop_statement>();
|
||||
current++;
|
||||
|
||||
} else {
|
||||
throw std::runtime_error("Unknown statement: " + name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,6 +197,7 @@ const func_builtins & global_builtins() {
|
|||
{"test_is_integer", test_type_fn<value_int>},
|
||||
{"test_is_number", test_type_fn<value_int, value_float>},
|
||||
{"test_is_iterable", test_type_fn<value_array, value_string>},
|
||||
{"test_is_sequence", test_type_fn<value_array, value_string>},
|
||||
{"test_is_mapping", test_type_fn<value_object>},
|
||||
{"test_is_lower", [](const func_args & args) -> value {
|
||||
args.ensure_vals<value_string>();
|
||||
|
|
@ -655,6 +656,10 @@ const func_builtins & value_object_t::get_builtins() const {
|
|||
}
|
||||
return result;
|
||||
}},
|
||||
{"string", [](const func_args & args) -> value {
|
||||
args.ensure_vals<value_object>();
|
||||
return mk_val<value_string>("TO BE IMPLEMENTED");
|
||||
}},
|
||||
{"tojson", [](const func_args & args) -> value {
|
||||
args.ensure_vals<value_object>();
|
||||
// use global to_json
|
||||
|
|
|
|||
|
|
@ -203,6 +203,14 @@ struct continue_statement : public statement {
|
|||
}
|
||||
};
|
||||
|
||||
// do nothing
|
||||
struct noop_statement : public statement {
|
||||
std::string type() const override { return "Noop"; }
|
||||
value execute_impl(context &) override {
|
||||
return mk_val<value_null>();
|
||||
}
|
||||
};
|
||||
|
||||
struct set_statement : public statement {
|
||||
statement_ptr assignee;
|
||||
statement_ptr val;
|
||||
|
|
|
|||
Loading…
Reference in New Issue