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

Function main

subprojects/llama.cpp/tests/test-grammar-llguidance.cpp:1147–1204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1145}
1146
1147int main(int argc, const char ** argv) {
1148 fprintf(stdout, "Running llguidance integration tests...\n");
1149
1150 if (argc != 2) {
1151 fprintf(stderr, "Usage: %s <vocab-file>\n", argv[0]);
1152 return 1;
1153 }
1154
1155 const char * vocab_file = argv[1];
1156
1157 fprintf(stderr, "reading vocab from: '%s'\n", vocab_file);
1158
1159 llama_model * model;
1160 llama_context * ctx;
1161
1162 llama_backend_init();
1163
1164 // load the vocab
1165 {
1166 auto mparams = llama_model_default_params();
1167
1168 mparams.vocab_only = true;
1169
1170 model = llama_model_load_from_file(vocab_file, mparams);
1171
1172 if (model == NULL) {
1173 fprintf(stderr, "%s: error: failed to load vocab '%s'\n", __func__, vocab_file);
1174 return 1;
1175 }
1176
1177 // needed?
1178 auto cparams = llama_context_default_params();
1179
1180 ctx = llama_init_from_model(model, cparams);
1181
1182 if (ctx == NULL) {
1183 fprintf(stderr, "%s: error: failed to load vocab '%s'\n", __func__, vocab_file);
1184 llama_model_free(model);
1185 return 1;
1186 }
1187 }
1188
1189 vocab = llama_model_get_vocab(model);
1190
1191 test_simple_grammar();
1192 test_complex_grammar();
1193 test_special_chars();
1194 test_quantifiers();
1195 test_json_schema();
1196
1197 test_sampler_chain();
1198
1199 llama_free(ctx);
1200 llama_model_free(model);
1201
1202 fprintf(stdout, "All tests passed.\n");
1203 return 0;
1204}

Callers

nothing calls this directly

Calls 14

llama_backend_initFunction · 0.85
llama_init_from_modelFunction · 0.85
llama_model_freeFunction · 0.85
llama_model_get_vocabFunction · 0.85
test_sampler_chainFunction · 0.85
llama_freeFunction · 0.85
test_simple_grammarFunction · 0.70
test_complex_grammarFunction · 0.70
test_special_charsFunction · 0.70

Tested by

no test coverage detected