11#include " run_cmd.h"
22#include " chat_completion_cmd.h"
33#include " config/yaml_config.h"
4+ #include " cortex_upd_cmd.h"
45#include " database/models.h"
56#include " model_start_cmd.h"
67#include " model_status_cmd.h"
78#include " server_start_cmd.h"
9+ #include " utils/cli_selection_utils.h"
810#include " utils/logging_utils.h"
911
10- #include " cortex_upd_cmd.h"
11-
1212namespace commands {
1313
1414namespace {
@@ -33,14 +33,21 @@ void RunCmd::Exec(bool chat_flag) {
3333
3434 // Download model if it does not exist
3535 {
36- if (!modellist_handler.HasModel (model_handle_)) {
36+ auto related_models_ids = modellist_handler.FindRelatedModel (model_handle_);
37+ if (related_models_ids.has_error () || related_models_ids.value ().empty ()) {
3738 auto result = model_service_.DownloadModel (model_handle_);
38- if (result.has_error ()) {
39- CTL_ERR (" Error: " << result.error ());
40- return ;
41- }
4239 model_id = result.value ();
4340 CTL_INF (" model_id: " << model_id.value ());
41+ } else if (related_models_ids.value ().size () == 1 ) {
42+ model_id = related_models_ids.value ().front ();
43+ } else { // multiple models with nearly same name found
44+ auto selection = cli_selection_utils::PrintSelection (
45+ related_models_ids.value (), " Local Models: (press enter to select)" );
46+ if (!selection.has_value ()) {
47+ return ;
48+ }
49+ model_id = selection.value ();
50+ CLI_LOG (" Selected: " << selection.value ());
4451 }
4552 }
4653
0 commit comments