Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 15d254e

Browse files
committed
Merge branch 'j/update-pull-command' of github.com:janhq/nitro into j/update-pull-command
2 parents 198e452 + 335ed1d commit 15d254e

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

engine/commands/run_cmd.cc

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
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-
1212
namespace commands {
1313

1414
namespace {
@@ -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

Comments
 (0)