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

Function get_expected_description

tests/test-chat.cpp:219–249  ·  view source on GitHub ↗

Get description of what the grammar expects at current position

Source from the content-addressed store, hash-verified

217
218// Get description of what the grammar expects at current position
219static std::string get_expected_description(const llama_grammar_rules & rules, const llama_grammar_stacks & stacks) {
220 if (stacks.empty()) {
221 return "<no valid continuations>";
222 }
223
224 std::string result;
225 std::set<std::string> seen;
226
227 for (const auto & stack : stacks) {
228 if (stack.empty()) {
229 if (seen.insert("<end>").second) {
230 if (!result.empty()) {
231 result += " OR ";
232 }
233 result += "<end>";
234 }
235 continue;
236 }
237
238 const llama_grammar_element * elem = stack.back();
239 std::string desc = format_expected_element(rules, elem);
240 if (seen.insert(desc).second) {
241 if (!result.empty()) {
242 result += " OR ";
243 }
244 result += desc;
245 }
246 }
247
248 return result;
249}
250
251// Result of a detailed grammar match attempt
252struct grammar_match_result {

Callers 1

match_string_detailedFunction · 0.85

Calls 3

format_expected_elementFunction · 0.85
emptyMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected