add placeholder for tojson
This commit is contained in:
parent
4479c382ce
commit
1b213ae5e7
|
|
@ -165,6 +165,11 @@ const func_builtins & global_builtins() {
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}},
|
}},
|
||||||
|
{"tojson", [](const func_args & args) -> value {
|
||||||
|
args.ensure_count(1);
|
||||||
|
// placeholder implementation
|
||||||
|
return mk_val<value_string>("TODO: to_json output");
|
||||||
|
}},
|
||||||
|
|
||||||
// tests
|
// tests
|
||||||
{"test_is_boolean", test_type_fn<value_bool>},
|
{"test_is_boolean", test_type_fn<value_bool>},
|
||||||
|
|
@ -646,7 +651,12 @@ const func_builtins & value_object_t::get_builtins() const {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}},
|
}},
|
||||||
{{"dictsort"}, [](const func_args & args) -> value {
|
{"tojson", [](const func_args & args) -> value {
|
||||||
|
args.ensure_vals<value_object>();
|
||||||
|
// use global to_json
|
||||||
|
return global_builtins().at("tojson")(args);
|
||||||
|
}},
|
||||||
|
{"dictsort", [](const func_args & args) -> value {
|
||||||
// no-op
|
// no-op
|
||||||
args.ensure_vals<value_object>();
|
args.ensure_vals<value_object>();
|
||||||
return args.args[0];
|
return args.args[0];
|
||||||
|
|
|
||||||
|
|
@ -312,10 +312,19 @@ value test_expression::execute_impl(context & ctx) {
|
||||||
throw std::runtime_error("Unknown test '" + test_id + "'");
|
throw std::runtime_error("Unknown test '" + test_id + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
value input = operand->execute(ctx);
|
||||||
|
|
||||||
func_args args(ctx);
|
func_args args(ctx);
|
||||||
args.args.push_back(operand->execute(ctx));
|
args.args.push_back(input);
|
||||||
auto res = it->second(args);
|
auto res = it->second(args);
|
||||||
|
|
||||||
|
// hack: allow type inference
|
||||||
|
if (test_id == "defined" || test_id == "undefined" || test_id == "none") {
|
||||||
|
ctx.mark_known_type(input, inferred_type::optional);
|
||||||
|
} else if (test_id == "string") {
|
||||||
|
ctx.mark_known_type(input, inferred_type::string);
|
||||||
|
}
|
||||||
|
|
||||||
if (negate) {
|
if (negate) {
|
||||||
return mk_val<value_bool>(!res->as_bool());
|
return mk_val<value_bool>(!res->as_bool());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -105,8 +105,9 @@ public:
|
||||||
if (is_val<value_object>(val)) {
|
if (is_val<value_object>(val)) {
|
||||||
auto & obj = val->as_object();
|
auto & obj = val->as_object();
|
||||||
for (const auto & pair : obj) {
|
for (const auto & pair : obj) {
|
||||||
flatten_globals[pair.first] = pair.second;
|
std::string child_path = path + "." + pair.first;
|
||||||
set_flattened_global_recursively(pair.first, pair.second);
|
flatten_globals[child_path] = pair.second;
|
||||||
|
set_flattened_global_recursively(child_path, pair.second);
|
||||||
}
|
}
|
||||||
} else if (is_val<value_array>(val)) {
|
} else if (is_val<value_array>(val)) {
|
||||||
auto & arr = val->as_array();
|
auto & arr = val->as_array();
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,21 @@ void run_single(std::string contents) {
|
||||||
{
|
{
|
||||||
"role": "assistant",
|
"role": "assistant",
|
||||||
"content": {"__input__": "I am fine, thank you!"}
|
"content": {"__input__": "I am fine, thank you!"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "assistant",
|
||||||
|
"content": "Calling weather tool.",
|
||||||
|
"tool_calls": [
|
||||||
|
{
|
||||||
|
"function": {
|
||||||
|
"name": "get_weather",
|
||||||
|
"arguments": {
|
||||||
|
"location": "New York",
|
||||||
|
"unit": "celsius"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bos_token": "<s>",
|
"bos_token": "<s>",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue