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

Commit f7e694a

Browse files
authored
Merge branch 'dev' into feat/api-docs
2 parents f80edba + 152b76f commit f7e694a

17 files changed

+534
-75
lines changed

.github/workflows/beta-build.yml

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
name: "${{ env.VERSION }}"
3636
draft: true
3737
prerelease: false
38+
generate_release_notes: true
3839

3940
build-macos:
4041
uses: ./.github/workflows/template-build-macos.yml
@@ -79,26 +80,52 @@ jobs:
7980
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
8081
cortex-llamacpp-version: ${{ needs.get-cortex-llamacpp-latest-version.outputs.cortex_llamacpp_latest_version }}
8182

82-
update_release_draft:
83-
needs: [build-macos, build-windows-x64, build-linux-x64]
83+
update_release:
84+
needs: [get-update-version, create-draft-release, build-macos, build-windows-x64, build-linux-x64]
85+
permissions:
86+
# write permission is required to create a github release
87+
contents: write
88+
# write permission is required for autolabeler
89+
# otherwise, read permission is required at least
90+
pull-requests: write
91+
runs-on: ubuntu-latest
92+
steps:
93+
- name: Getting the repo
94+
uses: actions/checkout@v4
95+
- name: set release to prerelease
96+
run: |
97+
gh release edit v${{ needs.get-update-version.outputs.new_version }} --draft=false --prerelease
98+
env:
99+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100+
101+
noti-discord:
102+
needs: [get-update-version, create-draft-release, build-macos, build-windows-x64, build-linux-x64, update_release]
103+
runs-on: ubuntu-latest
84104
permissions:
85-
# write permission is required to create a github release
86105
contents: write
87-
# write permission is required for autolabeler
88-
# otherwise, read permission is required at least
89-
pull-requests: write
90-
runs-on: ubuntu-latest
91106
steps:
92-
# (Optional) GitHub Enterprise requires GHE_HOST variable set
93-
#- name: Set GHE_HOST
94-
# run: |
95-
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV
107+
- name: Set version to environment variable
108+
run: |
109+
echo "VERSION=${{ needs.get-update-version.outputs.new_version }}" >> $GITHUB_ENV
110+
echo "RUNNER_ID=$GITHUB_RUN_ID" >> $GITHUB_ENV
96111
97-
# Drafts your next Release notes as Pull Requests are merged into "master"
98-
- uses: release-drafter/release-drafter@v5
99-
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
100-
# with:
101-
# config-name: my-config.yml
102-
# disable-autolabeler: true
103-
env:
104-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
- name: Notify Discord
113+
uses: appleboy/[email protected]
114+
with:
115+
webhook_id: ${{ secrets.WEBHOOK_ID_BETA }}
116+
webhook_token: ${{ secrets.WEBHOOK_TOKEN_BETA }}
117+
message: |
118+
Cortex.cpp beta build artifact version ${{ env.VERSION }}:
119+
- Windows:
120+
- Network Installer: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-windows-amd64-network-installer.exe
121+
- Local Installer: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-windows-amd64-local-installer.exe
122+
- Binary: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-windows-amd64.tar.gz
123+
- macOS Universal:
124+
- Network Installer: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-mac-universal-network-installer.pkg
125+
- Local Installer: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-mac-universal-local-installer.pkg
126+
- Binary: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-mac-universal.tar.gz
127+
- Linux Deb:
128+
- Network Installer: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-linux-amd64-network-installer.deb
129+
- Local Installer: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-linux-amd64-local-installer.deb
130+
- Binary: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-linux-amd64.tar.gz
131+
- Github Release: https://github.com/janhq/cortex.cpp/releases/tag/v${{ env.VERSION }}

.github/workflows/stable-build.yml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
name: "${{ env.VERSION }}"
3636
draft: true
3737
prerelease: false
38+
generate_release_notes: true
3839

3940
build-macos:
4041
uses: ./.github/workflows/template-build-macos.yml
@@ -78,27 +79,3 @@ jobs:
7879
channel: stable
7980
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
8081
cortex-llamacpp-version: ${{ needs.get-cortex-llamacpp-latest-version.outputs.cortex_llamacpp_latest_version }}
81-
82-
update_release_draft:
83-
needs: [build-macos, build-windows-x64, build-linux-x64]
84-
permissions:
85-
# write permission is required to create a github release
86-
contents: write
87-
# write permission is required for autolabeler
88-
# otherwise, read permission is required at least
89-
pull-requests: write
90-
runs-on: ubuntu-latest
91-
steps:
92-
# (Optional) GitHub Enterprise requires GHE_HOST variable set
93-
#- name: Set GHE_HOST
94-
# run: |
95-
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV
96-
97-
# Drafts your next Release notes as Pull Requests are merged into "master"
98-
- uses: release-drafter/release-drafter@v5
99-
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
100-
# with:
101-
# config-name: my-config.yml
102-
# disable-autolabeler: true
103-
env:
104-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ jobs:
3333
- Windows:
3434
- Network Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/windows-amd64/cortex-${{ env.VERSION }}-windows-amd64-network-installer.exe
3535
- Local Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/windows-amd64/cortex-${{ env.VERSION }}-windows-amd64-local-installer.exe
36+
- Binary: https://delta.jan.ai/cortex/v${{ env.VERSION }}/windows-amd64/cortex-nightly.tar.gz
3637
- macOS Universal:
3738
- Network Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/mac-universal/cortex-${{ env.VERSION }}-mac-universal-network-installer.pkg
3839
- Local Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/mac-universal/cortex-${{ env.VERSION }}-mac-universal-local-installer.pkg
40+
- Binary: https://delta.jan.ai/cortex/v${{ env.VERSION }}/mac-universal/cortex-nightly.tar.gz
3941
- Linux Deb:
4042
- Network Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/linux-amd64/cortex-${{ env.VERSION }}-linux-amd64-network-installer.deb
4143
- Local Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/linux-amd64/cortex-${{ env.VERSION }}-linux-amd64-local-installer.deb
44+
- Binary: https://delta.jan.ai/cortex/v${{ env.VERSION }}/linux-amd64/cortex-nightly.tar.gz
4245
- Github action run: https://github.com/janhq/cortex.cpp/actions/runs/${{ env.RUNNER_ID }}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Test cortexso Model Hub
2+
3+
on:
4+
schedule:
5+
- cron: "0 16 * * 5" # every Friday at 23:00 UTC+7
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-and-test:
10+
runs-on: ${{ matrix.runs-on }}
11+
timeout-minutes: 1440
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- os: "linux"
17+
name: "amd64"
18+
runs-on: "ubuntu-20-04-e2e-cortexcpp-model-hub"
19+
cmake-flags: "-DCORTEX_CPP_VERSION=${{github.head_ref}} -DCMAKE_BUILD_TEST=ON -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake"
20+
build-deps-cmake-flags: ""
21+
ccache-dir: ""
22+
steps:
23+
- name: Clone
24+
id: checkout
25+
uses: actions/checkout@v3
26+
with:
27+
submodules: recursive
28+
29+
- name: use python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: "3.10"
33+
34+
- name: Install tools on Linux
35+
run: |
36+
sudo chown -R runner:runner /home/runner/cortexcpp
37+
python3 -m pip install awscli
38+
39+
- name: Download vcpkg cache from s3
40+
continue-on-error: true
41+
run: |
42+
aws s3 sync s3://${{ secrets.MINIO_BUCKET_NAME }}/cortex-cpp-vcpkg-linux /home/runner/.cache/vcpkg --endpoint ${{ secrets.MINIO_ENDPOINT }} --cli-read-timeout 0
43+
env:
44+
AWS_ACCESS_KEY_ID: "${{ secrets.MINIO_ACCESS_KEY_ID }}"
45+
AWS_SECRET_ACCESS_KEY: "${{ secrets.MINIO_SECRET_ACCESS_KEY }}"
46+
AWS_DEFAULT_REGION: "${{ secrets.MINIO_REGION }}"
47+
48+
- name: Configure vcpkg
49+
run: |
50+
cd engine
51+
make configure-vcpkg
52+
53+
- name: Build
54+
run: |
55+
cd engine
56+
make build CMAKE_EXTRA_FLAGS="${{ matrix.cmake-flags }}" BUILD_DEPS_CMAKE_EXTRA_FLAGS="${{ matrix.build-deps-cmake-flags }}"
57+
58+
- name: Run unit tests
59+
run: |
60+
cd engine
61+
make run-unit-tests
62+
63+
- name: Run setup config for linux
64+
shell: bash
65+
run: |
66+
cd engine
67+
./build/cortex --version
68+
sed -i 's/huggingFaceToken: ""/huggingFaceToken: "${{ secrets.HUGGINGFACE_TOKEN_READ }}"/' ~/.cortexrc
69+
70+
- name: Run e2e tests
71+
run: |
72+
cd engine
73+
cp build/cortex build/cortex-nightly
74+
cp build/cortex build/cortex-beta
75+
python -m pip install --upgrade pip
76+
python -m pip install -r e2e-test/requirements.txt
77+
pytest e2e-test/test_api_cortexso_hub_llamacpp_engine.py
78+
rm build/cortex-nightly
79+
rm build/cortex-beta
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
HF_TOKEN: ${{ secrets.HUGGINGFACE_TOKEN_E2E }}
83+
84+
- name: Pre-package
85+
run: |
86+
cd engine
87+
make pre-package DESTINATION_BINARY_NAME="cortex"
88+
89+
- name: Package
90+
run: |
91+
cd engine
92+
make package
93+
94+
- name: Upload Artifact
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: cortex-${{ matrix.os }}-${{ matrix.name }}
98+
path: ./engine/cortex
99+
100+
101+
- name: Upload linux vcpkg cache to s3
102+
continue-on-error: true
103+
if: always()
104+
run: |
105+
aws s3 sync /home/runner/.cache/vcpkg s3://${{ secrets.MINIO_BUCKET_NAME }}/cortex-cpp-vcpkg-linux --endpoint ${{ secrets.MINIO_ENDPOINT }}
106+
env:
107+
AWS_ACCESS_KEY_ID: "${{ secrets.MINIO_ACCESS_KEY_ID }}"
108+
AWS_SECRET_ACCESS_KEY: "${{ secrets.MINIO_SECRET_ACCESS_KEY }}"
109+
AWS_DEFAULT_REGION: "${{ secrets.MINIO_REGION }}"

docs/static/openapi/cortex.json

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,46 @@
629629
]
630630
}
631631
},
632+
"/v1/models/import": {
633+
"post": {
634+
"operationId": "ModelsController_importModel",
635+
"summary": "Import model",
636+
"description": "Imports a model from a specified path.",
637+
"requestBody": {
638+
"required": true,
639+
"content": {
640+
"application/json": {
641+
"schema": {
642+
"$ref": "#/components/schemas/ImportModelRequest"
643+
},
644+
"example": {
645+
"model": "model-id",
646+
"modelPath": "/path/to/gguf",
647+
"name": "model display name"
648+
}
649+
}
650+
}
651+
},
652+
"responses": {
653+
"200": {
654+
"description": "Model is imported successfully!",
655+
"content": {
656+
"application/json": {
657+
"schema": {
658+
"$ref": "#/components/schemas/ImportModelResponse"
659+
},
660+
"example": {
661+
"message": "Model is imported successfully!",
662+
"modelHandle": "model-id",
663+
"result": "OK"
664+
}
665+
}
666+
}
667+
}
668+
},
669+
"tags": ["Models"]
670+
}
671+
},
632672
"/v1/threads": {
633673
"post": {
634674
"operationId": "ThreadsController_create",
@@ -2973,6 +3013,15 @@
29733013
"value": "my-custom-model-id"
29743014
}
29753015
]
3016+
},
3017+
"name": {
3018+
"type": "string",
3019+
"description": "The name which will be used to overwrite the model name.",
3020+
"examples": [
3021+
{
3022+
"value": "my-custom-model-name"
3023+
}
3024+
]
29763025
}
29773026
}
29783027
},
@@ -3126,6 +3175,43 @@
31263175
}
31273176
}
31283177
},
3178+
"ImportModelRequest": {
3179+
"type": "object",
3180+
"properties": {
3181+
"model": {
3182+
"type": "string",
3183+
"description": "The unique identifier of the model."
3184+
},
3185+
"modelPath": {
3186+
"type": "string",
3187+
"description": "The file path to the model."
3188+
},
3189+
"name": {
3190+
"type": "string",
3191+
"description": "The display name of the model."
3192+
}
3193+
},
3194+
"required": ["model", "modelPath"]
3195+
},
3196+
"ImportModelResponse": {
3197+
"type": "object",
3198+
"properties": {
3199+
"message": {
3200+
"type": "string",
3201+
"description": "Success message."
3202+
},
3203+
"modelHandle": {
3204+
"type": "string",
3205+
"description": "The unique identifier of the imported model."
3206+
},
3207+
"result": {
3208+
"type": "string",
3209+
"description": "Result status.",
3210+
"example": "OK"
3211+
}
3212+
},
3213+
"required": ["message", "modelHandle", "result"]
3214+
},
31293215
"CommonResponseDto": {
31303216
"type": "object",
31313217
"properties": {

engine/cli/commands/engine_install_cmd.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ bool EngineInstallCmd::Exec(const std::string& engine,
3535
DownloadProgress dp;
3636
dp.Connect(host_, port_);
3737
// engine can be small, so need to start ws first
38-
auto dp_res = std::async(std::launch::deferred,
39-
[&dp, &engine] { return dp.Handle(engine); });
38+
auto dp_res = std::async(std::launch::deferred, [&dp] {
39+
return dp.Handle(DownloadType::Engine);
40+
});
4041
CLI_LOG("Validating download items, please wait..")
4142

4243
httplib::Client cli(host_ + ":" + std::to_string(port_));
@@ -68,7 +69,7 @@ bool EngineInstallCmd::Exec(const std::string& engine,
6869

6970
bool check_cuda_download = !system_info_utils::GetCudaVersion().empty();
7071
if (check_cuda_download) {
71-
if (!dp.Handle("cuda"))
72+
if (!dp.Handle(DownloadType::CudaToolkit))
7273
return false;
7374
}
7475

engine/cli/commands/model_pull_cmd.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ std::optional<std::string> ModelPullCmd::Exec(const std::string& host, int port,
149149
reinterpret_cast<PHANDLER_ROUTINE>(console_ctrl_handler), true);
150150
#endif
151151
dp.Connect(host, port);
152-
if (!dp.Handle(model_id))
152+
if (!dp.Handle(DownloadType::Model))
153153
return std::nullopt;
154154
if (force_stop)
155155
return std::nullopt;

0 commit comments

Comments
 (0)