Skip to content

Commit

Permalink
fix: add dylib import path
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Jun 25, 2024
1 parent 1a17c1c commit e7dd5af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cortex-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"test:e2e": "jest --config ./test/jest-e2e.json",
"typeorm": "typeorm-ts-node-esm",
"build:dev": "npx nest build && chmod +x ./dist/src/command.js && npm link",
"postinstall": "npx --yes patch-package"
"postinstall": "npx -q patch-package"
},
"dependencies": {
"@huggingface/gguf": "^0.1.5",
Expand Down
22 changes: 21 additions & 1 deletion cortex-js/src/usecases/cortex/cortex.usecases.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { ChildProcess, spawn } from 'child_process';
import { join } from 'path';
import { delimiter, join } from 'path';
import { CortexOperationSuccessfullyDto } from '@/infrastructure/dtos/cortex/cortex-operation-successfully.dto';
import { HttpService } from '@nestjs/axios';

Expand All @@ -11,6 +11,7 @@ import {
CORTEX_CPP_HEALTH_Z_URL,
CORTEX_CPP_PROCESS_DESTROY_URL,
} from '@/infrastructure/constants/cortex';
import { Engines } from '@/infrastructure/commanders/types/engine.interface';

@Injectable()
export class CortexUsecases {
Expand Down Expand Up @@ -44,6 +45,8 @@ export class CortexUsecases {
throw new Error('The engine is not available, please run "cortex init".');
}

await this.addAdditionalDependencies();

// go up one level to get the binary folder, have to also work on windows
this.cortexProcess = spawn(cortexCppPath, args, {
detached: !attach,
Expand Down Expand Up @@ -114,4 +117,21 @@ export class CortexUsecases {
})
.catch(() => false);
}

private async addAdditionalDependencies() {
const cortexCPPPath = join(
await this.fileManagerService.getDataFolderPath(),
'cortex-cpp',
);
const paths = delimiter.concat(
...[Engines.llamaCPP, Engines.onnx, Engines.tensorrtLLM].map((e) =>
join(cortexCPPPath, e),
),
);
// Set the updated PATH
process.env.PATH = (process.env.PATH || '').concat(paths);
process.env.LD_LIBRARY_PATH = (process.env.LD_LIBRARY_PATH || '').concat(
paths,
);
}
}

0 comments on commit e7dd5af

Please sign in to comment.