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

Function run_single

tests/test-chat-template.cpp:279–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277
278
279void run_single(const std::string& contents, json input, bool use_common, const std::string & output_path) {
280 jinja::enable_debug(true);
281
282 jinja::value_string output_parts;
283
284 if (use_common) {
285 std::string bos_token = "<s>";
286 std::string eos_token = "</s>";
287 if (input.contains("bos_token")) {
288 bos_token = input["bos_token"].get<std::string>();
289 }
290 if (input.contains("eos_token")) {
291 eos_token = input["eos_token"].get<std::string>();
292 }
293 nlohmann::ordered_json msgs_json = input["messages"];
294 nlohmann::ordered_json tools_json = input["tools"];
295 auto messages = common_chat_msgs_parse_oaicompat(msgs_json);
296 auto tools = common_chat_tools_parse_oaicompat(tools_json);
297 auto output = format_using_common(contents, bos_token, eos_token, messages, tools);
298 std::cout << "\n=== OUTPUT ===\n";
299 std::cout << output << "\n";
300 output_parts = jinja::mk_val<jinja::value_string>(output);
301
302 } else {
303 output_parts = format_using_direct_engine(contents, input);
304 std::cout << "\n=== OUTPUT ===\n";
305 std::cout << output_parts->as_string().str() << "\n";
306 }
307
308 if (!output_path.empty()) {
309 std::ofstream outfile(output_path);
310 if (!outfile) {
311 throw std::runtime_error("Could not open output file: " + output_path);
312 }
313 outfile << output_parts->as_string().str();
314 outfile.close();
315 std::cout << "\n=== OUTPUT WRITTEN TO " << output_path << " ===\n";
316 }
317}
318
319
320

Callers 2

mainFunction · 0.85
run_multipleFunction · 0.85

Calls 10

enable_debugFunction · 0.85
format_using_commonFunction · 0.85
containsMethod · 0.80
strMethod · 0.45
as_stringMethod · 0.45
emptyMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected