Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion engine/commands/chat_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ ChatCmd::ChatCmd(std::string host, int port, const config::ModelConfig& mc)
void ChatCmd::Exec(std::string msg) {
auto address = host_ + ":" + std::to_string(port_);
// Check if model is loaded
{
// TODO(sang) only llamacpp support modelstatus for now
if (mc_.engine.find("llamacpp") != std::string::npos) {
httplib::Client cli(address);
nlohmann::json json_data;
json_data["model"] = mc_.name;
Expand All @@ -56,6 +57,7 @@ void ChatCmd::Exec(std::string msg) {
return;
}
}

// Some instruction for user here
std::cout << "Inorder to exit, type `exit()`" << std::endl;
// Model is loaded, start to chat
Expand Down
18 changes: 12 additions & 6 deletions engine/controllers/command_line_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ bool CommandLineParser::SetupCommand(int argc, char** argv) {
auto start_cmd = models_cmd->add_subcommand("start", "Start a model by ID");
start_cmd->add_option("model_id", model_id, "");
start_cmd->callback([&model_id]() {
// TODO(sang) switch to <model_id>.yaml when implement model manager
commands::CmdInfo ci(model_id);
std::string model_file =
ci.branch == "main" ? ci.model_name : ci.model_name + "-" + ci.branch;
config::YamlHandler yaml_handler;
yaml_handler.ModelConfigFromFile(cortex_utils::GetCurrentPath() +
"/models/" + model_id + "/model.yml");
"/models/" + model_file + ".yaml");
commands::ModelStartCmd msc("127.0.0.1", 3928,
yaml_handler.GetModelConfig());
msc.Exec();
Expand All @@ -38,10 +40,12 @@ bool CommandLineParser::SetupCommand(int argc, char** argv) {
models_cmd->add_subcommand("stop", "Stop a model by ID");
stop_model_cmd->add_option("model_id", model_id, "");
stop_model_cmd->callback([&model_id]() {
// TODO(sang) switch to <model_id>.yaml when implement model manager
commands::CmdInfo ci(model_id);
std::string model_file =
ci.branch == "main" ? ci.model_name : ci.model_name + "-" + ci.branch;
config::YamlHandler yaml_handler;
yaml_handler.ModelConfigFromFile(cortex_utils::GetCurrentPath() +
"/models/" + model_id + "/model.yml");
"/models/" + model_file + ".yaml");
commands::StopModelCmd smc("127.0.0.1", 3928,
yaml_handler.GetModelConfig());
smc.Exec();
Expand Down Expand Up @@ -90,10 +94,12 @@ bool CommandLineParser::SetupCommand(int argc, char** argv) {
chat_cmd->add_option("-m,--message", msg, "Message to chat with model");

chat_cmd->callback([&model_id, &msg] {
// TODO(sang) switch to <model_id>.yaml when implement model manager
commands::CmdInfo ci(model_id);
std::string model_file =
ci.branch == "main" ? ci.model_name : ci.model_name + "-" + ci.branch;
config::YamlHandler yaml_handler;
yaml_handler.ModelConfigFromFile(cortex_utils::GetCurrentPath() +
"/models/" + model_id + "/model.yml");
"/models/" + model_file + ".yaml");
commands::ChatCmd cc("127.0.0.1", 3928, yaml_handler.GetModelConfig());
cc.Exec(msg);
});
Expand Down