Skip to content

Commit

Permalink
Merge branch 'dev' into feat/api-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-menlo authored Nov 1, 2024
2 parents f80edba + 152b76f commit f7e694a
Show file tree
Hide file tree
Showing 17 changed files with 534 additions and 75 deletions.
65 changes: 46 additions & 19 deletions .github/workflows/beta-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
name: "${{ env.VERSION }}"
draft: true
prerelease: false
generate_release_notes: true

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

update_release_draft:
needs: [build-macos, build-windows-x64, build-linux-x64]
update_release:
needs: [get-update-version, create-draft-release, build-macos, build-windows-x64, build-linux-x64]
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Getting the repo
uses: actions/checkout@v4
- name: set release to prerelease
run: |
gh release edit v${{ needs.get-update-version.outputs.new_version }} --draft=false --prerelease
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
noti-discord:
needs: [get-update-version, create-draft-release, build-macos, build-windows-x64, build-linux-x64, update_release]
runs-on: ubuntu-latest
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV
- name: Set version to environment variable
run: |
echo "VERSION=${{ needs.get-update-version.outputs.new_version }}" >> $GITHUB_ENV
echo "RUNNER_ID=$GITHUB_RUN_ID" >> $GITHUB_ENV
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
# with:
# config-name: my-config.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Notify Discord
uses: appleboy/[email protected]
with:
webhook_id: ${{ secrets.WEBHOOK_ID_BETA }}
webhook_token: ${{ secrets.WEBHOOK_TOKEN_BETA }}
message: |
Cortex.cpp beta build artifact version ${{ env.VERSION }}:
- Windows:
- Network Installer: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-windows-amd64-network-installer.exe
- Local Installer: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-windows-amd64-local-installer.exe
- Binary: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-windows-amd64.tar.gz
- macOS Universal:
- Network Installer: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-mac-universal-network-installer.pkg
- Local Installer: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-mac-universal-local-installer.pkg
- Binary: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-mac-universal.tar.gz
- Linux Deb:
- Network Installer: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-linux-amd64-network-installer.deb
- Local Installer: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-linux-amd64-local-installer.deb
- Binary: https://github.com/janhq/cortex.cpp/releases/download/v${{ env.VERSION }}/cortex-${{ env.VERSION }}-linux-amd64.tar.gz
- Github Release: https://github.com/janhq/cortex.cpp/releases/tag/v${{ env.VERSION }}
25 changes: 1 addition & 24 deletions .github/workflows/stable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
name: "${{ env.VERSION }}"
draft: true
prerelease: false
generate_release_notes: true

build-macos:
uses: ./.github/workflows/template-build-macos.yml
Expand Down Expand Up @@ -78,27 +79,3 @@ jobs:
channel: stable
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
cortex-llamacpp-version: ${{ needs.get-cortex-llamacpp-latest-version.outputs.cortex_llamacpp_latest_version }}

update_release_draft:
needs: [build-macos, build-windows-x64, build-linux-x64]
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV

# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
# with:
# config-name: my-config.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .github/workflows/template-noti-discord.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ jobs:
- Windows:
- Network Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/windows-amd64/cortex-${{ env.VERSION }}-windows-amd64-network-installer.exe
- Local Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/windows-amd64/cortex-${{ env.VERSION }}-windows-amd64-local-installer.exe
- Binary: https://delta.jan.ai/cortex/v${{ env.VERSION }}/windows-amd64/cortex-nightly.tar.gz
- macOS Universal:
- Network Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/mac-universal/cortex-${{ env.VERSION }}-mac-universal-network-installer.pkg
- Local Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/mac-universal/cortex-${{ env.VERSION }}-mac-universal-local-installer.pkg
- Binary: https://delta.jan.ai/cortex/v${{ env.VERSION }}/mac-universal/cortex-nightly.tar.gz
- Linux Deb:
- Network Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/linux-amd64/cortex-${{ env.VERSION }}-linux-amd64-network-installer.deb
- Local Installer: https://delta.jan.ai/cortex/v${{ env.VERSION }}/linux-amd64/cortex-${{ env.VERSION }}-linux-amd64-local-installer.deb
- Binary: https://delta.jan.ai/cortex/v${{ env.VERSION }}/linux-amd64/cortex-nightly.tar.gz
- Github action run: https://github.com/janhq/cortex.cpp/actions/runs/${{ env.RUNNER_ID }}
109 changes: 109 additions & 0 deletions .github/workflows/test-cortexso-model-hub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Test cortexso Model Hub

on:
schedule:
- cron: "0 16 * * 5" # every Friday at 23:00 UTC+7
workflow_dispatch:

jobs:
build-and-test:
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 1440
strategy:
fail-fast: false
matrix:
include:
- os: "linux"
name: "amd64"
runs-on: "ubuntu-20-04-e2e-cortexcpp-model-hub"
cmake-flags: "-DCORTEX_CPP_VERSION=${{github.head_ref}} -DCMAKE_BUILD_TEST=ON -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake"
build-deps-cmake-flags: ""
ccache-dir: ""
steps:
- name: Clone
id: checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: use python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install tools on Linux
run: |
sudo chown -R runner:runner /home/runner/cortexcpp
python3 -m pip install awscli
- name: Download vcpkg cache from s3
continue-on-error: true
run: |
aws s3 sync s3://${{ secrets.MINIO_BUCKET_NAME }}/cortex-cpp-vcpkg-linux /home/runner/.cache/vcpkg --endpoint ${{ secrets.MINIO_ENDPOINT }} --cli-read-timeout 0
env:
AWS_ACCESS_KEY_ID: "${{ secrets.MINIO_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.MINIO_SECRET_ACCESS_KEY }}"
AWS_DEFAULT_REGION: "${{ secrets.MINIO_REGION }}"

- name: Configure vcpkg
run: |
cd engine
make configure-vcpkg
- name: Build
run: |
cd engine
make build CMAKE_EXTRA_FLAGS="${{ matrix.cmake-flags }}" BUILD_DEPS_CMAKE_EXTRA_FLAGS="${{ matrix.build-deps-cmake-flags }}"
- name: Run unit tests
run: |
cd engine
make run-unit-tests
- name: Run setup config for linux
shell: bash
run: |
cd engine
./build/cortex --version
sed -i 's/huggingFaceToken: ""/huggingFaceToken: "${{ secrets.HUGGINGFACE_TOKEN_READ }}"/' ~/.cortexrc
- name: Run e2e tests
run: |
cd engine
cp build/cortex build/cortex-nightly
cp build/cortex build/cortex-beta
python -m pip install --upgrade pip
python -m pip install -r e2e-test/requirements.txt
pytest e2e-test/test_api_cortexso_hub_llamacpp_engine.py
rm build/cortex-nightly
rm build/cortex-beta
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HF_TOKEN: ${{ secrets.HUGGINGFACE_TOKEN_E2E }}

- name: Pre-package
run: |
cd engine
make pre-package DESTINATION_BINARY_NAME="cortex"
- name: Package
run: |
cd engine
make package
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: cortex-${{ matrix.os }}-${{ matrix.name }}
path: ./engine/cortex


- name: Upload linux vcpkg cache to s3
continue-on-error: true
if: always()
run: |
aws s3 sync /home/runner/.cache/vcpkg s3://${{ secrets.MINIO_BUCKET_NAME }}/cortex-cpp-vcpkg-linux --endpoint ${{ secrets.MINIO_ENDPOINT }}
env:
AWS_ACCESS_KEY_ID: "${{ secrets.MINIO_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.MINIO_SECRET_ACCESS_KEY }}"
AWS_DEFAULT_REGION: "${{ secrets.MINIO_REGION }}"
86 changes: 86 additions & 0 deletions docs/static/openapi/cortex.json
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,46 @@
]
}
},
"/v1/models/import": {
"post": {
"operationId": "ModelsController_importModel",
"summary": "Import model",
"description": "Imports a model from a specified path.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ImportModelRequest"
},
"example": {
"model": "model-id",
"modelPath": "/path/to/gguf",
"name": "model display name"
}
}
}
},
"responses": {
"200": {
"description": "Model is imported successfully!",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ImportModelResponse"
},
"example": {
"message": "Model is imported successfully!",
"modelHandle": "model-id",
"result": "OK"
}
}
}
}
},
"tags": ["Models"]
}
},
"/v1/threads": {
"post": {
"operationId": "ThreadsController_create",
Expand Down Expand Up @@ -2973,6 +3013,15 @@
"value": "my-custom-model-id"
}
]
},
"name": {
"type": "string",
"description": "The name which will be used to overwrite the model name.",
"examples": [
{
"value": "my-custom-model-name"
}
]
}
}
},
Expand Down Expand Up @@ -3126,6 +3175,43 @@
}
}
},
"ImportModelRequest": {
"type": "object",
"properties": {
"model": {
"type": "string",
"description": "The unique identifier of the model."
},
"modelPath": {
"type": "string",
"description": "The file path to the model."
},
"name": {
"type": "string",
"description": "The display name of the model."
}
},
"required": ["model", "modelPath"]
},
"ImportModelResponse": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "Success message."
},
"modelHandle": {
"type": "string",
"description": "The unique identifier of the imported model."
},
"result": {
"type": "string",
"description": "Result status.",
"example": "OK"
}
},
"required": ["message", "modelHandle", "result"]
},
"CommonResponseDto": {
"type": "object",
"properties": {
Expand Down
7 changes: 4 additions & 3 deletions engine/cli/commands/engine_install_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ bool EngineInstallCmd::Exec(const std::string& engine,
DownloadProgress dp;
dp.Connect(host_, port_);
// engine can be small, so need to start ws first
auto dp_res = std::async(std::launch::deferred,
[&dp, &engine] { return dp.Handle(engine); });
auto dp_res = std::async(std::launch::deferred, [&dp] {
return dp.Handle(DownloadType::Engine);
});
CLI_LOG("Validating download items, please wait..")

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

bool check_cuda_download = !system_info_utils::GetCudaVersion().empty();
if (check_cuda_download) {
if (!dp.Handle("cuda"))
if (!dp.Handle(DownloadType::CudaToolkit))
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion engine/cli/commands/model_pull_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ std::optional<std::string> ModelPullCmd::Exec(const std::string& host, int port,
reinterpret_cast<PHANDLER_ROUTINE>(console_ctrl_handler), true);
#endif
dp.Connect(host, port);
if (!dp.Handle(model_id))
if (!dp.Handle(DownloadType::Model))
return std::nullopt;
if (force_stop)
return std::nullopt;
Expand Down
Loading

0 comments on commit f7e694a

Please sign in to comment.