Skip to content

Commit

Permalink
fix: electron build (#908)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-menlo authored Jul 24, 2024
1 parent 4165a06 commit 777f914
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
19 changes: 19 additions & 0 deletions cortex-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +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()

Expand Down Expand Up @@ -76,7 +83,19 @@ if(DEFINED CMAKE_JS_INC)

add_library(${PROJECT_NAME} SHARED addon.cc
${CMAKE_CURRENT_SOURCE_DIR}/utils/cpuid/cpu_info.cc
${CMAKE_JS_SRC}
)

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
Expand Down
2 changes: 1 addition & 1 deletion cortex-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions cortex-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '@/infrastructure/constants/cortex';
import { getApp } from './app';
import chalk from 'chalk';
import { CortexUsecases } from './usecases/cortex/cortex.usecases';

/**
* Start the API server
Expand All @@ -17,6 +18,8 @@ export async function start(host?: string, port?: number) {

try {
await app.listen(sPort, sHost);
const cortexUsecases = await app.resolve(CortexUsecases);
await cortexUsecases.startCortex();
console.log(chalk.blue(`Started server at http://${sHost}:${sPort}`));
console.log(
chalk.blue(`API Playground available at http://${sHost}:${sPort}/api`),
Expand Down
5 changes: 4 additions & 1 deletion cortex-js/src/usecases/chat/chat.usecases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 777f914

Please sign in to comment.