MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / caps_try_execute

Function caps_try_execute

subprojects/llama.cpp/common/jinja/caps.cpp:21–49  ·  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 try {
40 jinja::runtime runtime(ctx);
41 runtime.execute(prog);
42 success = true;
43 } catch (const std::exception & e) {
44 JJ_DEBUG("Exception during execution: %s", e.what());
45 // ignore exceptions during capability analysis
46 }
47
48 analyze_fn(success, messages, tools);
49}
50
51// for debugging only
52static void caps_print_stats(value & v, const std::string & path) {

Callers 1

caps_getFunction · 0.85

Calls 4

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

Tested by

no test coverage detected