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

Commit 4fcb40c

Browse files
nguyenhoangthuan99vansangpfievsangjanai
authored
Fix/skip re download model yml (#1409)
* feat: relative path for data (part1) * chore: unit tests * fix: unit tests * fix: more * fix: windows * fix: comments * fix: use fs path * Fix: redownload model.yml * chore: move logic to file manager utils (#1405) * Fix: unable to shorten model alias --------- Co-authored-by: vansangpfiev <vansangpfiev@gmail.com> Co-authored-by: vansangpfiev <sang@jan.ai>
1 parent 8657549 commit 4fcb40c

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

engine/database/models.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ std::string Models::GenerateShortenedAlias(
8686
std::vector<std::string> parts;
8787
std::istringstream iss(model_id);
8888
std::string part;
89-
while (std::getline(iss, part, '/')) {
89+
while (std::getline(iss, part, ':')) {
9090
parts.push_back(part);
9191
}
9292

@@ -115,12 +115,12 @@ std::string Models::GenerateShortenedAlias(
115115

116116
if (parts.size() >= 3) {
117117
candidates.push_back(parts[parts.size() - 3] + ":" +
118-
parts[parts.size() - 2] + "/" + filename);
118+
parts[parts.size() - 2] + ":" + filename);
119119
}
120120

121121
if (parts.size() >= 4) {
122-
candidates.push_back(parts[0] + ":" + parts[1] + "/" +
123-
parts[parts.size() - 2] + "/" + filename);
122+
candidates.push_back(parts[0] + ":" + parts[1] + ":" +
123+
parts[parts.size() - 2] + ":" + filename);
124124
}
125125

126126
// Find the first unique candidate

engine/services/download_service.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ cpp::result<bool, std::string> DownloadService::AddDownloadTask(
7272
if (result.has_error()) {
7373
dl_err_msg = result.error();
7474
break;
75-
} else if(result) {
75+
} else if (result) {
7676
has_task_done |= result.value();
7777
}
7878
}
@@ -175,7 +175,9 @@ cpp::result<bool, std::string> DownloadService::Download(
175175
<< " - " << existing_file_size);
176176
CTL_INF("Download item size: " << download_item.bytes.value());
177177
auto missing_bytes = download_item.bytes.value() - existing_file_size;
178-
if (missing_bytes > 0) {
178+
if (missing_bytes > 0 &&
179+
download_item.localPath.extension().string() != ".yaml" &&
180+
download_item.localPath.extension().string() != ".yml") {
179181
CLI_LOG("Found unfinished download! Additional "
180182
<< format_utils::BytesToHumanReadable(missing_bytes)
181183
<< " need to be downloaded.");
@@ -186,7 +188,7 @@ cpp::result<bool, std::string> DownloadService::Download(
186188
mode = "ab";
187189
CLI_LOG("Resuming download..");
188190
} else {
189-
CLI_LOG("Start over..");
191+
CLI_LOG("Start over..");
190192
}
191193
} else {
192194
CLI_LOG(download_item.localPath.filename().string()

engine/test/components/test_models_db.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ TEST_F(ModelsTestSuite, TestGenerateShortenedAlias) {
8585
EXPECT_TRUE(model_list_.AddModelEntry(kTestModel).value());
8686
auto models1 = model_list_.LoadModelList();
8787
auto alias = model_list_.GenerateShortenedAlias(
88-
"huggingface.co/bartowski/llama3.1-7b-gguf/Model_ID_Xxx.gguf",
88+
"huggingface.co:bartowski:llama3.1-7b-gguf:Model_ID_Xxx.gguf",
8989
models1.value());
9090
EXPECT_EQ(alias, "model_id_xxx");
9191
EXPECT_TRUE(model_list_.UpdateModelAlias(kTestModel.model, alias).value());
9292

9393
// Test with existing entries to force longer alias
9494
auto models2 = model_list_.LoadModelList();
9595
alias = model_list_.GenerateShortenedAlias(
96-
"huggingface.co/bartowski/llama3.1-7b-gguf/Model_ID_Xxx.gguf",
96+
"huggingface.co:bartowski:llama3.1-7b-gguf:Model_ID_Xxx.gguf",
9797
models2.value());
9898
EXPECT_EQ(alias, "llama3.1-7b-gguf:model_id_xxx");
9999

engine/utils/file_manager_utils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ inline void CreateConfigFileIfNotExist() {
144144

145145
auto config = config_yaml_utils::CortexConfig{
146146
.logFolderPath = defaultDataFolderPath.string(),
147+
.logLlamaCppPath = kLogsLlamacppBaseName,
148+
.logTensorrtLLMPath = kLogsTensorrtllmBaseName,
149+
.logOnnxPath = kLogsOnnxBaseName,
147150
.dataFolderPath = defaultDataFolderPath.string(),
148151
.maxLogLines = config_yaml_utils::kDefaultMaxLines,
149152
.apiServerHost = config_yaml_utils::kDefaultHost,

0 commit comments

Comments
 (0)