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
3 changes: 2 additions & 1 deletion engine/commands/chat_completion_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ void ChatCompletionCmd::Exec(const std::string& host, int port,
}

// Only check if llamacpp engine
if ((mc.engine.find("llamacpp") != std::string::npos) &&
if ((mc.engine.find(kLlamaEngine) != std::string::npos ||
mc.engine.find(kLlamaRepo) != std::string::npos) &&
!commands::ModelStatusCmd().IsLoaded(host, port, model_handle)) {
CLI_LOG("Model is not loaded yet!");
return;
Expand Down
4 changes: 3 additions & 1 deletion engine/commands/ps_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string>
#include <tabulate/table.hpp>
#include "nlohmann/json.hpp"
#include "utils/engine_constants.h"
#include "utils/format_utils.h"
#include "utils/logging_utils.h"
#include "utils/string_utils.h"
Expand All @@ -26,7 +27,8 @@ void PsCmd::Exec(const std::string& host, int port) {
try {
for (const auto& item : data) {
ModelLoadedStatus model_status;
model_status.engine = item["engine"];
// TODO(sang) hardcode for now
model_status.engine = kLlamaEngine;
model_status.model = item["id"];
model_status.ram = item["ram"];
model_status.start_time = item["start_time"];
Expand Down
17 changes: 16 additions & 1 deletion engine/commands/run_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@

namespace commands {

namespace {
std::string Repo2Engine(const std::string& r) {
if (r == kLlamaRepo) {
return kLlamaEngine;
} else if (r == kOnnxRepo) {
return kOnnxEngine;
} else if (r == kTrtLlmRepo) {
return kTrtLlmEngine;
}
return r;
};
} // namespace

void RunCmd::Exec(bool chat_flag) {
std::optional<std::string> model_id = model_handle_;

Expand Down Expand Up @@ -47,7 +60,9 @@ void RunCmd::Exec(bool chat_flag) {

// Check if engine existed. If not, download it
{
auto required_engine = engine_service_.GetEngineInfo(mc.engine);
auto required_engine =
engine_service_.GetEngineInfo(Repo2Engine(mc.engine));

if (!required_engine.has_value()) {
throw std::runtime_error("Engine not found: " + mc.engine);
}
Expand Down
3 changes: 2 additions & 1 deletion engine/config/gguf_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "gguf_parser.h"
#include "trantor/utils/Logger.h"
#include "utils/engine_constants.h"

namespace config {
#define NOMINMAX
Expand Down Expand Up @@ -401,7 +402,7 @@ void GGUFHandler::ModelConfigFromMetadata() {
model_config_.frequency_penalty = 0;
model_config_.presence_penalty = 0;
model_config_.stream = true;
model_config_.engine = "cortex.llamacpp";
model_config_.engine = kLlamaEngine;
model_config_.created = std::time(nullptr);
model_config_.model = "model";
model_config_.owned_by = "";
Expand Down
10 changes: 7 additions & 3 deletions engine/config/yaml_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#include <iostream>
#include <string>

#include "utils/format_utils.h"
#include "utils/engine_constants.h"
#include "utils/file_manager_utils.h"
#include "utils/format_utils.h"
#include "yaml_config.h"
namespace config {
// Method to read YAML file
Expand All @@ -25,10 +26,12 @@ void YamlHandler::ReadYamlFile(const std::string& file_path) {
std::replace(s.begin(), s.end(), '\\', '/');
std::vector<std::string> v;
if (yaml_node_["engine"] &&
yaml_node_["engine"].as<std::string>() == "cortex.llamacpp") {
(yaml_node_["engine"].as<std::string>() == kLlamaRepo ||
(yaml_node_["engine"].as<std::string>() == kLlamaEngine))) {
auto abs_path = s.substr(0, s.find_last_of('/')) + "/model.gguf";
auto rel_path = fmu::ToRelativeCortexDataPath(fs::path(abs_path));
v.emplace_back(rel_path.string());

} else {
v.emplace_back(s.substr(0, s.find_last_of('/')));
}
Expand Down Expand Up @@ -289,7 +292,8 @@ void YamlHandler::WriteYamlFile(const std::string& file_path) const {
outFile << "version: " << yaml_node_["version"].as<std::string>() << "\n";
}
if (yaml_node_["files"] && yaml_node_["files"].size()) {
outFile << "files: # Can be relative OR absolute local file path\n";
outFile << "files: # Can be relative OR absolute local file "
"path\n";
for (const auto& source : yaml_node_["files"]) {
outFile << " - " << source << "\n";
}
Expand Down
Loading
Loading