11import { Injectable } from '@nestjs/common' ;
22import { ChildProcess , spawn } from 'child_process' ;
3- import { join } from 'path' ;
3+ import { delimiter , join } from 'path' ;
44import { CortexOperationSuccessfullyDto } from '@/infrastructure/dtos/cortex/cortex-operation-successfully.dto' ;
55import { HttpService } from '@nestjs/axios' ;
66
@@ -11,6 +11,7 @@ import {
1111 CORTEX_CPP_HEALTH_Z_URL ,
1212 CORTEX_CPP_PROCESS_DESTROY_URL ,
1313} from '@/infrastructure/constants/cortex' ;
14+ import { Engines } from '@/infrastructure/commanders/types/engine.interface' ;
1415
1516@Injectable ( )
1617export class CortexUsecases {
@@ -44,6 +45,11 @@ export class CortexUsecases {
4445 throw new Error ( 'The engine is not available, please run "cortex init".' ) ;
4546 }
4647
48+ const cortexCPPPath = join (
49+ await this . fileManagerService . getDataFolderPath ( ) ,
50+ 'cortex-cpp' ,
51+ ) ;
52+
4753 // go up one level to get the binary folder, have to also work on windows
4854 this . cortexProcess = spawn ( cortexCppPath , args , {
4955 detached : ! attach ,
@@ -52,6 +58,11 @@ export class CortexUsecases {
5258 env : {
5359 ...process . env ,
5460 CUDA_VISIBLE_DEVICES : '0' ,
61+ PATH : ( process . env . PATH || '' ) . concat ( delimiter , cortexCPPPath ) ,
62+ LD_LIBRARY_PATH : ( process . env . LD_LIBRARY_PATH || '' ) . concat (
63+ delimiter ,
64+ cortexCPPPath ,
65+ ) ,
5566 // // Vulkan - Support 1 device at a time for now
5667 // ...(executableOptions.vkVisibleDevices?.length > 0 && {
5768 // GGML_VULKAN_DEVICE: executableOptions.vkVisibleDevices[0],
0 commit comments