MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / caps_try_execute

Function caps_try_execute

common/jinja/caps.cpp:21–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19using caps_analyze_fn = std::function<void(bool, value &, value &)>;
20
21static void caps_try_execute(jinja::program & prog,
22 const caps_json_fn & messages_fn,
23 const caps_json_fn & tools_fn,
24 const caps_analyze_fn & analyze_fn) {
25 context ctx;
26 ctx.is_get_stats = true;
27 jinja::global_from_json(ctx, json{
28 {"messages", messages_fn()},
29 {"tools", tools_fn()},
30 {"bos_token", ""},
31 {"eos_token", ""},
32 {"add_generation_prompt", true}
33 }, true);
34
35 auto messages = ctx.get_val("messages");
36 auto tools = ctx.get_val("tools");
37
38 bool success = false;
39 std::string result;
40 try {
41 jinja::runtime runtime(ctx);
42 auto results = runtime.execute(prog);
43 auto parts = jinja::runtime::gather_string_parts(results);
44 result = parts->as_string().str();
45 success = true;
46 } catch (const std::exception & e) {
47 JJ_DEBUG("Exception during execution: %s", e.what());
48 result = "";
49 // ignore exceptions during capability analysis
50 }
51
52 analyze_fn(success, messages, tools);
53}
54
55// for debugging only
56static void caps_print_stats(value & v, const std::string & path) {

Callers 1

caps_getFunction · 0.85

Calls 6

global_from_jsonFunction · 0.85
get_valMethod · 0.80
executeMethod · 0.45
strMethod · 0.45
as_stringMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected