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

Commit 5c7519a

Browse files
committed
Merge branch 'dev' into feat/e2e-test-ci
2 parents f7fdd42 + d67029b commit 5c7519a

File tree

11 files changed

+897
-59
lines changed

11 files changed

+897
-59
lines changed

.github/workflows/nightly-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ jobs:
124124
AWS_EC2_METADATA_DISABLED: "true"
125125

126126
noti-discord-nightly-and-update-url-readme:
127-
needs: [build-macos-x64, build-macos-arm64, build-windows-x64, build-linux-x64, get-update-version, set-public-provider, get-cortex-llamacpp-latest-version]
127+
needs: [build-macos-x64, build-macos-arm64, build-windows-x64, build-linux-x64, get-update-version, set-public-provider, get-cortex-llamacpp-latest-version, update-latest-version]
128128
secrets: inherit
129129
if: github.event_name == 'schedule'
130130
uses: ./.github/workflows/template-noti-discord.yaml

.github/workflows/template-noti-discord.yaml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,26 @@ jobs:
2020
- name: Set version to environment variable
2121
run: |
2222
echo "VERSION=${{ inputs.new_version }}" >> $GITHUB_ENV
23+
echo "RUNNER_ID=$GITHUB_RUN_ID" >> $GITHUB_ENV
24+
echo "BUILD_REASON=${{ inputs.build_reason }}" >> $GITHUB_ENV
2325
2426
- name: Notify Discord
25-
uses: Ilshidur/action-discord@master
27+
uses: appleboy/discord-action@v1.0.0
2628
with:
27-
args: |
28-
Cortex.cpp ${{ inputs.build_reason }} build artifact version {{ VERSION }}:
29+
webhook_id: ${{ secrets.WEBHOOK_ID }}
30+
webhook_token: ${{ secrets.WEBHOOK_TOKEN }}
31+
message: |
32+
Cortex.cpp ${{ env.BUILD_REASON }} build artifact version ${{ env.VERSION }}:
2933
- Windows:
30-
- Network Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/windows-amd64/cortex-{{ VERSION }}-windows-amd64-network-installer.exe
31-
- Local Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/windows-amd64/cortex-{{ VERSION }}-windows-amd64-local-installer.exe
34+
- Network Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/windows-amd64/cortex-${{ env.VERSION }}-windows-amd64-network-installer.exe
35+
- Local Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/windows-amd64/cortex-${{ env.VERSION }}-windows-amd64-local-installer.exe
3236
- macOS Intel:
33-
- Network Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/mac-amd64/cortex-{{ VERSION }}-mac-amd64-network-installer.pkg
34-
- Local Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/mac-amd64/cortex-{{ VERSION }}-mac-amd64-local-installer.pkg
37+
- Network Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/mac-amd64/cortex-${{ env.VERSION }}-mac-amd64-network-installer.pkg
38+
- Local Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/mac-amd64/cortex-${{ env.VERSION }}-mac-amd64-local-installer.pkg
3539
- macOS Apple Silicon:
36-
- Network Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/mac-arm64/cortex-{{ VERSION }}-mac-arm64-network-installer.pkg
37-
- Local Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/mac-arm64/cortex-{{ VERSION }}-mac-arm64-local-installer.pkg
40+
- Network Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/mac-arm64/cortex-${{ env.VERSION }}-mac-arm64-network-installer.pkg
41+
- Local Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/mac-arm64/cortex-${{ env.VERSION }}-mac-arm64-local-installer.pkg
3842
- Linux Deb:
39-
- Network Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/linux-amd64/cortex-{{ VERSION }}-linux-amd64-network-installer.deb
40-
- Local Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/linux-amd64/cortex-{{ VERSION }}-linux-amd64-local-installer.deb
41-
- Github action run: https://github.com/janhq/cortex.cpp/actions/runs/{{ GITHUB_RUN_ID }}
42-
env:
43-
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
43+
- Network Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/linux-amd64/cortex-${{ env.VERSION }}-linux-amd64-network-installer.deb
44+
- Local Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/linux-amd64/cortex-${{ env.VERSION }}-linux-amd64-local-installer.deb
45+
- Github action run: https://github.com/janhq/cortex.cpp/actions/runs/${{ env.RUNNER_ID }}

engine/commands/model_alias_cmd.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ void ModelAliasCmd::Exec(const std::string& model_handle,
77
const std::string& model_alias) {
88
cortex::db::Models modellist_handler;
99
try {
10-
if (modellist_handler.UpdateModelAlias(model_handle, model_alias)) {
11-
CLI_LOG("Successfully set model alias '" + model_alias +
12-
"' for modeID '" + model_handle + "'.");
10+
auto result = modellist_handler.UpdateModelAlias(model_handle, model_alias);
11+
if (result.has_error()) {
12+
CLI_LOG(result.error());
1313
} else {
14-
CLI_LOG("Unable to set model alias for modelID '" + model_handle +
15-
"': model alias '" + model_alias + "' is not unique!");
14+
if (result.value()) {
15+
CLI_LOG("Successfully set model alias '" + model_alias +
16+
"' for modeID '" + model_handle + "'.");
17+
} else {
18+
CLI_LOG("Unable to set model alias for modelID '" + model_handle +
19+
"': model alias '" + model_alias + "' is not unique!");
20+
}
1621
}
22+
1723
} catch (const std::exception& e) {
1824
CLI_LOG("Error when setting model alias ('" + model_alias +
1925
"') for modelID '" + model_handle + "':" + e.what());

engine/controllers/models.cc

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,13 @@ void Models::GetModel(
120120
config::YamlHandler yaml_handler;
121121
auto model_entry = modellist_handler.GetModelInfo(model_handle);
122122
if (model_entry.has_error()) {
123-
CLI_LOG("Error: " + model_entry.error());
123+
// CLI_LOG("Error: " + model_entry.error());
124+
ret["data"] = data;
125+
ret["result"] = "Fail to get model information";
126+
ret["message"] = "Error: " + model_entry.error();
127+
auto resp = cortex_utils::CreateCortexHttpJsonResponse(ret);
128+
resp->setStatusCode(k400BadRequest);
129+
callback(resp);
124130
return;
125131
}
126132
yaml_handler.ModelConfigFromFile(model_entry.value().path_to_model_yaml);
@@ -234,7 +240,7 @@ void Models::ImportModel(
234240
gguf_handler.Parse(modelPath);
235241
config::ModelConfig model_config = gguf_handler.GetModelConfig();
236242
model_config.files.push_back(modelPath);
237-
model_config.name = modelHandle;
243+
model_config.model = modelHandle;
238244
yaml_handler.UpdateModelConfig(model_config);
239245

240246
if (modellist_utils_obj.AddModelEntry(model_entry).value()) {
@@ -293,29 +299,42 @@ void Models::SetModelAlias(
293299

294300
cortex::db::Models modellist_handler;
295301
try {
296-
if (modellist_handler.UpdateModelAlias(model_handle, model_alias)) {
297-
std::string message = "Successfully set model alias '" + model_alias +
298-
"' for modeID '" + model_handle + "'.";
299-
LOG_INFO << message;
300-
Json::Value ret;
301-
ret["result"] = "OK";
302-
ret["modelHandle"] = model_handle;
303-
ret["message"] = message;
304-
auto resp = cortex_utils::CreateCortexHttpJsonResponse(ret);
305-
resp->setStatusCode(k200OK);
306-
callback(resp);
307-
} else {
308-
std::string message = "Unable to set model alias for modelID '" +
309-
model_handle + "': model alias '" + model_alias +
310-
"' is not unique!";
302+
auto result = modellist_handler.UpdateModelAlias(model_handle, model_alias);
303+
if (result.has_error()) {
304+
std::string message = result.error();
311305
LOG_ERROR << message;
312-
Json::Value ret;
313-
ret["result"] = "Set alias failed!";
314-
ret["modelHandle"] = model_handle;
315-
ret["message"] = message;
316-
auto resp = cortex_utils::CreateCortexHttpJsonResponse(ret);
317-
resp->setStatusCode(k400BadRequest);
318-
callback(resp);
306+
Json::Value ret;
307+
ret["result"] = "Set alias failed!";
308+
ret["modelHandle"] = model_handle;
309+
ret["message"] = message;
310+
auto resp = cortex_utils::CreateCortexHttpJsonResponse(ret);
311+
resp->setStatusCode(k400BadRequest);
312+
callback(resp);
313+
} else {
314+
if (result.value()) {
315+
std::string message = "Successfully set model alias '" + model_alias +
316+
"' for modeID '" + model_handle + "'.";
317+
LOG_INFO << message;
318+
Json::Value ret;
319+
ret["result"] = "OK";
320+
ret["modelHandle"] = model_handle;
321+
ret["message"] = message;
322+
auto resp = cortex_utils::CreateCortexHttpJsonResponse(ret);
323+
resp->setStatusCode(k200OK);
324+
callback(resp);
325+
} else {
326+
std::string message = "Unable to set model alias for modelID '" +
327+
model_handle + "': model alias '" + model_alias +
328+
"' is not unique!";
329+
LOG_ERROR << message;
330+
Json::Value ret;
331+
ret["result"] = "Set alias failed!";
332+
ret["modelHandle"] = model_handle;
333+
ret["message"] = message;
334+
auto resp = cortex_utils::CreateCortexHttpJsonResponse(ret);
335+
resp->setStatusCode(k400BadRequest);
336+
callback(resp);
337+
}
319338
}
320339
} catch (const std::exception& e) {
321340
std::string message = "Error when setting model alias ('" + model_alias +

engine/controllers/models.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Models : public drogon::HttpController<Models> {
1414
METHOD_ADD(Models::PullModel, "/pull", Post);
1515
METHOD_ADD(Models::ListModel, "", Get);
1616
METHOD_ADD(Models::GetModel, "/get", Post);
17-
METHOD_ADD(Models::UpdateModel, "/update/", Post);
17+
METHOD_ADD(Models::UpdateModel, "/update", Post);
1818
METHOD_ADD(Models::ImportModel, "/import", Post);
1919
METHOD_ADD(Models::DeleteModel, "/{1}", Delete);
2020
METHOD_ADD(Models::SetModelAlias, "/alias", Post);

0 commit comments

Comments
 (0)