| 274 | } |
| 275 | |
| 276 | int main(int argc, char ** argv) { |
| 277 | ggml_time_init(); |
| 278 | |
| 279 | common_params params; |
| 280 | |
| 281 | if (!common_params_parse(argc, argv, params, LLAMA_EXAMPLE_MTMD, show_additional_info)) { |
| 282 | return 1; |
| 283 | } |
| 284 | |
| 285 | common_init(); |
| 286 | mtmd_helper_log_set(common_log_default_callback, nullptr); |
| 287 | |
| 288 | if (params.mmproj.path.empty()) { |
| 289 | show_additional_info(argc, argv); |
| 290 | LOG_ERR("ERR: Missing --mmproj argument\n"); |
| 291 | return 1; |
| 292 | } |
| 293 | |
| 294 | mtmd_cli_context ctx(params); |
| 295 | LOG_INF("%s: loading model: %s\n", __func__, params.model.path.c_str()); |
| 296 | |
| 297 | bool is_single_turn = !params.prompt.empty() && !params.image.empty(); |
| 298 | |
| 299 | int n_predict = params.n_predict < 0 ? INT_MAX : params.n_predict; |
| 300 | |
| 301 | // Ctrl+C handling |
| 302 | { |
| 303 | #if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) |
| 304 | struct sigaction sigint_action; |
| 305 | sigint_action.sa_handler = sigint_handler; |
| 306 | sigemptyset (&sigint_action.sa_mask); |
| 307 | sigint_action.sa_flags = 0; |
| 308 | sigaction(SIGINT, &sigint_action, NULL); |
| 309 | #elif defined (_WIN32) |
| 310 | auto console_ctrl_handler = +[](DWORD ctrl_type) -> BOOL { |
| 311 | return (ctrl_type == CTRL_C_EVENT) ? (sigint_handler(SIGINT), true) : false; |
| 312 | }; |
| 313 | SetConsoleCtrlHandler(reinterpret_cast<PHANDLER_ROUTINE>(console_ctrl_handler), true); |
| 314 | #endif |
| 315 | } |
| 316 | |
| 317 | if (g_is_interrupted) return 130; |
| 318 | |
| 319 | auto eval_system_prompt_if_present = [&] { |
| 320 | if (params.system_prompt.empty()) { |
| 321 | return 0; |
| 322 | } |
| 323 | |
| 324 | common_chat_msg msg; |
| 325 | msg.role = "system"; |
| 326 | msg.content = params.system_prompt; |
| 327 | return eval_message(ctx, msg); |
| 328 | }; |
| 329 | |
| 330 | LOG_WRN("WARN: This is an experimental CLI for testing multimodal capability.\n"); |
| 331 | LOG_WRN(" For normal use cases, please use the standard llama-cli\n"); |
| 332 | |
| 333 | if (eval_system_prompt_if_present()) { |
nothing calls this directly
no test coverage detected