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

Commit 22ff0a1

Browse files
Feat/python engine (#1784)
* chore: add document * feat: update engine interface * chore: add document * feat: update engine interface * Feat: init python engine * Fix: conflict * feat: add python engine implementation * Fix: CI build window * Fix: CI build window * feat: support download python model from cortexso * feat: add inference interface * feat: integrate to cortex cpp * fix: remove pythone engine load engine option * Feat: init environment interface * feat: move virtual environment inside model * Update CMakeLists.txt * Update CMakeLists.txt * fix: CI build * fix: move log of python to cortex logs folder * fix: unitest for remote engine because change location of template renderer * fix: CI build windows * fix: CI build windows * feat: add depends model.yml for python engine * fix: CI build * update set permission api * Fix: comment * Fix: remove unnecessary interface * Fix comment * Fix: comment review --------- Co-authored-by: James <namnh0122@gmail.com>
1 parent 3b545de commit 22ff0a1

28 files changed

+1882
-40
lines changed

engine/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,14 @@ file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/cortex_openapi.h"
142142
add_executable(${TARGET_NAME} main.cc
143143
${CMAKE_CURRENT_SOURCE_DIR}/utils/cpuid/cpu_info.cc
144144
${CMAKE_CURRENT_SOURCE_DIR}/utils/file_logger.cc
145+
146+
${CMAKE_CURRENT_SOURCE_DIR}/extensions/template_renderer.cc
147+
${CMAKE_CURRENT_SOURCE_DIR}/extensions/python-engine/python_engine.cc
148+
145149
${CMAKE_CURRENT_SOURCE_DIR}/utils/dylib_path_manager.cc
150+
146151
${CMAKE_CURRENT_SOURCE_DIR}/extensions/remote-engine/remote_engine.cc
147-
${CMAKE_CURRENT_SOURCE_DIR}/extensions/remote-engine/template_renderer.cc
152+
148153
)
149154

150155
target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

engine/cli/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ add_executable(${TARGET_NAME} main.cc
8585
${CMAKE_CURRENT_SOURCE_DIR}/../services/hardware_service.cc
8686
${CMAKE_CURRENT_SOURCE_DIR}/../services/database_service.cc
8787
${CMAKE_CURRENT_SOURCE_DIR}/../extensions/remote-engine/remote_engine.cc
88-
${CMAKE_CURRENT_SOURCE_DIR}/../extensions/remote-engine/template_renderer.cc
88+
89+
${CMAKE_CURRENT_SOURCE_DIR}/../extensions/python-engine/python_engine.cc
90+
${CMAKE_CURRENT_SOURCE_DIR}/../extensions/template_renderer.cc
91+
8992
${CMAKE_CURRENT_SOURCE_DIR}/utils/easywsclient.cc
9093
${CMAKE_CURRENT_SOURCE_DIR}/utils/download_progress.cc
9194
${CMAKE_CURRENT_SOURCE_DIR}/../utils/config_yaml_utils.cc

engine/common/base.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using namespace drogon;
55

66
class BaseModel {
77
public:
8-
virtual ~BaseModel() {}
8+
virtual ~BaseModel() = default;
99

1010
// Model management
1111
virtual void LoadModel(
@@ -27,7 +27,7 @@ class BaseModel {
2727

2828
class BaseChatCompletion {
2929
public:
30-
virtual ~BaseChatCompletion() {}
30+
virtual ~BaseChatCompletion() = default;
3131

3232
// General chat method
3333
virtual void ChatCompletion(
@@ -37,7 +37,7 @@ class BaseChatCompletion {
3737

3838
class BaseEmbedding {
3939
public:
40-
virtual ~BaseEmbedding() {}
40+
virtual ~BaseEmbedding() = default;
4141

4242
// Implement embedding functionality specific to chat
4343
virtual void Embedding(
@@ -46,3 +46,4 @@ class BaseEmbedding {
4646

4747
// The derived class can also override other methods if needed
4848
};
49+

engine/common/download_task.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
#include <sstream>
77
#include <string>
88

9-
enum class DownloadType { Model, Engine, Miscellaneous, CudaToolkit, Cortex };
9+
enum class DownloadType {
10+
Model,
11+
Engine,
12+
Miscellaneous,
13+
CudaToolkit,
14+
Cortex,
15+
Environments
16+
};
1017

1118
struct DownloadItem {
1219

@@ -48,6 +55,8 @@ inline std::string DownloadTypeToString(DownloadType type) {
4855
return "CudaToolkit";
4956
case DownloadType::Cortex:
5057
return "Cortex";
58+
case DownloadType::Environments:
59+
return "Environments";
5160
default:
5261
return "Unknown";
5362
}
@@ -64,6 +73,8 @@ inline DownloadType DownloadTypeFromString(const std::string& str) {
6473
return DownloadType::CudaToolkit;
6574
} else if (str == "Cortex") {
6675
return DownloadType::Cortex;
76+
} else if (str == "Environments") {
77+
return DownloadType::Environments;
6778
} else {
6879
return DownloadType::Miscellaneous;
6980
}

0 commit comments

Comments
 (0)