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

Commit e963e63

Browse files
authored
fix: use model_id.yaml for model info (#1051)
1 parent 1b23363 commit e963e63

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

engine/commands/chat_cmd.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ ChatCmd::ChatCmd(std::string host, int port, const config::ModelConfig& mc)
3434
void ChatCmd::Exec(std::string msg) {
3535
auto address = host_ + ":" + std::to_string(port_);
3636
// Check if model is loaded
37-
{
37+
// TODO(sang) only llamacpp support modelstatus for now
38+
if (mc_.engine.find("llamacpp") != std::string::npos) {
3839
httplib::Client cli(address);
3940
nlohmann::json json_data;
4041
json_data["model"] = mc_.name;
@@ -56,6 +57,7 @@ void ChatCmd::Exec(std::string msg) {
5657
return;
5758
}
5859
}
60+
5961
// Some instruction for user here
6062
std::cout << "Inorder to exit, type `exit()`" << std::endl;
6163
// Model is loaded, start to chat

engine/controllers/command_line_parser.cc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ bool CommandLineParser::SetupCommand(int argc, char** argv) {
2525
auto start_cmd = models_cmd->add_subcommand("start", "Start a model by ID");
2626
start_cmd->add_option("model_id", model_id, "");
2727
start_cmd->callback([&model_id]() {
28-
// TODO(sang) switch to <model_id>.yaml when implement model manager
28+
commands::CmdInfo ci(model_id);
29+
std::string model_file =
30+
ci.branch == "main" ? ci.model_name : ci.model_name + "-" + ci.branch;
2931
config::YamlHandler yaml_handler;
3032
yaml_handler.ModelConfigFromFile(cortex_utils::GetCurrentPath() +
31-
"/models/" + model_id + "/model.yml");
33+
"/models/" + model_file + ".yaml");
3234
commands::ModelStartCmd msc("127.0.0.1", 3928,
3335
yaml_handler.GetModelConfig());
3436
msc.Exec();
@@ -38,10 +40,12 @@ bool CommandLineParser::SetupCommand(int argc, char** argv) {
3840
models_cmd->add_subcommand("stop", "Stop a model by ID");
3941
stop_model_cmd->add_option("model_id", model_id, "");
4042
stop_model_cmd->callback([&model_id]() {
41-
// TODO(sang) switch to <model_id>.yaml when implement model manager
43+
commands::CmdInfo ci(model_id);
44+
std::string model_file =
45+
ci.branch == "main" ? ci.model_name : ci.model_name + "-" + ci.branch;
4246
config::YamlHandler yaml_handler;
4347
yaml_handler.ModelConfigFromFile(cortex_utils::GetCurrentPath() +
44-
"/models/" + model_id + "/model.yml");
48+
"/models/" + model_file + ".yaml");
4549
commands::StopModelCmd smc("127.0.0.1", 3928,
4650
yaml_handler.GetModelConfig());
4751
smc.Exec();
@@ -90,10 +94,12 @@ bool CommandLineParser::SetupCommand(int argc, char** argv) {
9094
chat_cmd->add_option("-m,--message", msg, "Message to chat with model");
9195

9296
chat_cmd->callback([&model_id, &msg] {
93-
// TODO(sang) switch to <model_id>.yaml when implement model manager
97+
commands::CmdInfo ci(model_id);
98+
std::string model_file =
99+
ci.branch == "main" ? ci.model_name : ci.model_name + "-" + ci.branch;
94100
config::YamlHandler yaml_handler;
95101
yaml_handler.ModelConfigFromFile(cortex_utils::GetCurrentPath() +
96-
"/models/" + model_id + "/model.yml");
102+
"/models/" + model_file + ".yaml");
97103
commands::ChatCmd cc("127.0.0.1", 3928, yaml_handler.GetModelConfig());
98104
cc.Exec(msg);
99105
});

0 commit comments

Comments
 (0)