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

Function main

subprojects/llama.cpp/tests/test-chat-template.cpp:60–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58})";
59
60int main(int argc, char ** argv) {
61 std::vector<std::string> args(argv, argv + argc);
62
63 std::string tmpl_path;
64 std::string json_path;
65 std::string output_path;
66 bool stop_on_first_fail = false;
67 bool use_common = true;
68
69 for (size_t i = 1; i < args.size(); i++) {
70 if (args[i] == "--help" || args[i] == "-h") {
71 std::cout << HELP << "\n";
72 return 0;
73 } else if (args[i] == "--json" && i + 1 < args.size()) {
74 json_path = args[i + 1];
75 i++;
76 } else if (args[i] == "--stop-on-first-fail") {
77 stop_on_first_fail = true;
78 } else if (args[i] == "--output" && i + 1 < args.size()) {
79 output_path = args[i + 1];
80 i++;
81 } else if (args[i] == "--no-common") {
82 use_common = true;
83 } else if (tmpl_path.empty()) {
84 tmpl_path = args[i];
85 } else {
86 std::cerr << "Unknown argument: " << args[i] << "\n";
87 std::cout << HELP << "\n";
88 return 1;
89 }
90 }
91
92 if (tmpl_path.empty()) {
93 return main_automated_tests();
94 }
95
96 json input_json;
97 if (!json_path.empty()) {
98 std::ifstream json_file(json_path);
99 if (!json_file) {
100 std::cerr << "Error: Could not open JSON file: " << json_path << "\n";
101 return 1;
102 }
103 std::string content = std::string(
104 std::istreambuf_iterator<char>(json_file),
105 std::istreambuf_iterator<char>());
106 input_json = json::parse(content);
107 } else {
108 input_json = json::parse(DEFAULT_JSON);
109 }
110
111 std::filesystem::path p(tmpl_path);
112 if (std::filesystem::is_directory(p)) {
113 run_multiple(tmpl_path, stop_on_first_fail, input_json, use_common);
114 } else if (std::filesystem::is_regular_file(p)) {
115 std::ifstream infile(tmpl_path);
116 std::string contents = std::string(
117 std::istreambuf_iterator<char>(infile),

Callers

nothing calls this directly

Calls 7

main_automated_testsFunction · 0.85
stringClass · 0.85
parseFunction · 0.85
run_multipleFunction · 0.85
run_singleFunction · 0.85
sizeMethod · 0.65
emptyMethod · 0.65

Tested by

no test coverage detected