@@ -396,7 +396,7 @@ static bool parse_bool_value(const std::string & value) {
396396// CLI argument parsing functions
397397//
398398
399- bool common_params_handle_models (common_params & params, llama_example curr_ex) {
399+ bool common_params_handle_models (common_params & params, llama_example curr_ex, common_download_callback * callback ) {
400400 const bool spec_type_draft_mtp = std::find (params.speculative .types .begin (),
401401 params.speculative .types .end (),
402402 COMMON_SPECULATIVE_TYPE_DRAFT_MTP ) != params.speculative .types .end ();
@@ -408,6 +408,10 @@ bool common_params_handle_models(common_params & params, llama_example curr_ex)
408408 opts.download_mtp = spec_type_draft_mtp;
409409 opts.download_mmproj = !params.no_mmproj && params.mmproj .path .empty () && params.mmproj .url .empty ();
410410
411+ if (callback) {
412+ opts.callback = callback;
413+ }
414+
411415 // sub-models (draft, mmproj, vocoder) are explicitly specified by the user,
412416 // so we should not auto-discover mtp/mmproj siblings for them
413417 common_download_opts sub_opts = opts;
@@ -584,8 +588,11 @@ static bool common_params_parse_ex(int argc, char ** argv, common_params_context
584588 throw std::invalid_argument (" error: --prompt-cache-all not supported in interactive mode yet\n " );
585589 }
586590
587- // export_graph_ops loads only metadata
588- const bool skip_model_download = ctx_arg.ex == LLAMA_EXAMPLE_EXPORT_GRAPH_OPS ;
591+ const bool skip_model_download =
592+ // server will call common_params_handle_models() later, so we skip it here
593+ ctx_arg.ex == LLAMA_EXAMPLE_SERVER ||
594+ // export_graph_ops loads only metadata
595+ ctx_arg.ex == LLAMA_EXAMPLE_EXPORT_GRAPH_OPS ;
589596
590597 if (!skip_model_download) {
591598 // handle model and download
@@ -594,7 +601,6 @@ static bool common_params_parse_ex(int argc, char ** argv, common_params_context
594601 // model is required (except for server)
595602 // TODO @ngxson : maybe show a list of available models in CLI in this case
596603 if (params.model .path .empty ()
597- && ctx_arg.ex != LLAMA_EXAMPLE_SERVER
598604 && !params.usage
599605 && !params.completion ) {
600606 throw std::invalid_argument (" error: --model is required\n " );
0 commit comments