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

Function caps_get

subprojects/llama.cpp/common/jinja/caps.cpp:85–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85caps caps_get(jinja::program & prog) {
86 caps result;
87
88 static const auto has_op = [](value & v, const std::string & op_name) {
89 return v->stats.ops.find(op_name) != v->stats.ops.end();
90 };
91
92 // case: typed content requirement
93 caps_try_execute(
94 prog,
95 [&]() {
96 // messages
97 return json::array({
98 {
99 {"role", "user"},
100 {"content", "content"}
101 }
102 });
103 },
104 [&]() {
105 // tools
106 return json{nullptr};
107 },
108 [&](bool, value & messages, value &) {
109 auto & content = messages->at(0)->at("content");
110 caps_print_stats(content, "messages[0].content");
111 if (has_op(content, "selectattr") || has_op(content, "array_access")) {
112 // accessed as an array
113 result.requires_typed_content = true;
114 }
115 }
116 );
117
118
119 // case: system prompt support
120 caps_try_execute(
121 prog,
122 [&]() {
123 // messages
124 return json::array({
125 {
126 {"role", "system"},
127 {"content", "System message"}
128 },
129 {
130 {"role", "user"},
131 {"content", "User message"}
132 },
133 });
134 },
135 [&]() {
136 // tools
137 return json::array();
138 },
139 [&](bool, value & messages, value &) {
140 auto & content = messages->at(0)->at("content");
141 caps_print_stats(content, "messages[0].content");
142 if (!content->stats.used) {

Callers 2

common_chat_templateMethod · 0.85

Calls 6

caps_try_executeFunction · 0.85
caps_print_statsFunction · 0.85
findMethod · 0.65
atMethod · 0.65
endMethod · 0.45
to_stringMethod · 0.45

Tested by 1