From a784e804d676777e79eb00794bb3d7502ebe9d25 Mon Sep 17 00:00:00 2001 From: Louis Le Date: Wed, 24 Jul 2024 10:57:14 +0700 Subject: [PATCH] fix: electron build is broken on Windows --- cortex-cpp/CMakeLists.txt | 20 ++++++++++++-------- cortex-js/package.json | 2 +- cortex-js/src/usecases/chat/chat.usecases.ts | 5 ++++- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/cortex-cpp/CMakeLists.txt b/cortex-cpp/CMakeLists.txt index 1800cc8e7..a53e9fa70 100644 --- a/cortex-cpp/CMakeLists.txt +++ b/cortex-cpp/CMakeLists.txt @@ -4,11 +4,13 @@ project(cortex-cpp C CXX) # Build using CMAKE-JS if(DEFINED CMAKE_JS_INC) + if(WIN32) add_definitions( -DV8_COMPRESS_POINTERS -DV8_REVERSE_JSARGS -DV8_COMPRESS_POINTERS_IN_ISOLATE_CAGE ) + endif() include_directories(${CMAKE_JS_INC}) endif() @@ -84,14 +86,16 @@ if(DEFINED CMAKE_JS_INC) ${CMAKE_JS_SRC} ) - target_link_libraries(${PROJECT_NAME} - PRIVATE - msvcprt.lib - msvcrt.lib - vcruntime.lib - ucrt.lib - ${CMAKE_JS_LIB} - ) + if(WIN32) + target_link_libraries(${PROJECT_NAME} + PRIVATE + msvcprt.lib + msvcrt.lib + vcruntime.lib + ucrt.lib + ${CMAKE_JS_LIB} + ) + endif() else() # Official build add_executable(${PROJECT_NAME} main.cc ${CMAKE_CURRENT_SOURCE_DIR}/utils/cpuid/cpu_info.cc diff --git a/cortex-js/package.json b/cortex-js/package.json index 81dd98da3..2711965ac 100644 --- a/cortex-js/package.json +++ b/cortex-js/package.json @@ -54,7 +54,7 @@ "class-transformer": "^0.5.1", "class-validator": "^0.14.1", "cli-progress": "^3.12.0", - "cortex-cpp": "0.4.25", + "cortex-cpp": "0.4.34", "cortexso-node": "^0.0.4", "cpu-instructions": "^0.0.11", "decompress": "^4.2.1", diff --git a/cortex-js/src/usecases/chat/chat.usecases.ts b/cortex-js/src/usecases/chat/chat.usecases.ts index 7c0854181..190c24f96 100644 --- a/cortex-js/src/usecases/chat/chat.usecases.ts +++ b/cortex-js/src/usecases/chat/chat.usecases.ts @@ -50,7 +50,10 @@ export class ChatUsecases { throw new Error(`No engine found with name: ${model.engine}`); } try { - return await engine.inference(createChatDto, headers); + return await engine.inference( + { ...createChatDto, engine: model.engine }, + headers, + ); } catch (error) { await this.telemetryUseCases.createCrashReport( error,