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

Commit b6f4a91

Browse files
committed
fix: gate ONNX on other OSs
1 parent 192a891 commit b6f4a91

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

cortex-js/src/infrastructure/commanders/models/model-pull.command.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ export class ModelPullCommand extends CommandRunner {
4747

4848
// Pull engine if not exist
4949
if (
50-
!existsSync(
51-
join(await this.fileService.getDataFolderPath(), 'engines', engine),
52-
)
50+
!existsSync(join(await this.fileService.getCortexCppEnginePath(), engine))
5351
) {
52+
console.log('\n');
5453
await this.initUsecases.installEngine(
5554
await this.initUsecases.defaultInstallationOptions(),
5655
'latest',

cortex-js/src/infrastructure/commanders/models/model-start.command.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,18 @@ export class ModelStartCommand extends CommandRunner {
6363
const engine = existingModel.engine || 'cortex.llamacpp';
6464
// Pull engine if not exist
6565
if (
66-
!existsSync(
67-
join(await this.fileService.getDataFolderPath(), 'engines', engine),
68-
)
66+
!existsSync(join(await this.fileService.getCortexCppEnginePath(), engine))
6967
) {
7068
await this.initUsecases.installEngine(
7169
await this.initUsecases.defaultInstallationOptions(),
7270
'latest',
7371
engine,
7472
);
7573
}
74+
if (engine === 'cortex.onnx' && process.platform !== 'win32') {
75+
console.error('The ONNX engine does not support this OS yet.');
76+
process.exit(1);
77+
}
7678
await this.cortexUsecases
7779
.startCortex(options.attach)
7880
.then(() => this.modelsCliUsecases.startModel(modelId, options.preset))

cortex-js/src/infrastructure/commanders/usecases/init.cli.usecases.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,19 @@ export class InitCliUsecases {
6363
if (
6464
!existsSync(
6565
join(
66-
await this.fileManagerService.getDataFolderPath(),
67-
'engines',
68-
engine,
66+
await this.fileManagerService.getCortexCppEnginePath(),
67+
'cortex.llamacpp',
6968
),
7069
)
7170
)
7271
await this.installLlamaCppEngine(options, version);
7372

74-
if (engine === 'cortex.onnx')
75-
if (process.platform === 'win32') await this.installONNXEngine();
73+
if (engine === 'cortex.onnx' && process.platform === 'win32')
74+
await this.installONNXEngine();
75+
else if (engine === 'cortex.onnx' && process.platform !== 'win32') {
76+
console.error('The ONNX engine does not support this OS yet.');
77+
process.exit(1);
78+
}
7679

7780
configs.initialized = true;
7881
await this.fileManagerService.writeConfigFile(configs);

cortex-js/src/infrastructure/services/file-manager/file-manager.service.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,21 @@ export class FileManagerService {
234234
/**
235235
* Get the benchmark folder path
236236
* Usually it is located at the home directory > cortex > extensions
237-
* @returns the path to the extensions folder
237+
* @returns the path to the benchmark folder
238238
*/
239239
async getBenchmarkPath(): Promise<string> {
240240
const dataFolderPath = await this.getDataFolderPath();
241241
return join(dataFolderPath, this.benchmarkFoldername);
242242
}
243243

244+
/**
245+
* Get Cortex CPP engines folder path
246+
* @returns the path to the cortex engines folder
247+
*/
248+
async getCortexCppEnginePath(): Promise<string> {
249+
return join(await this.getDataFolderPath(), 'cortex-cpp', 'engines');
250+
}
251+
244252
async createFolderIfNotExistInDataFolder(folderName: string): Promise<void> {
245253
const dataFolderPath = await this.getDataFolderPath();
246254
const folderPath = join(dataFolderPath, folderName);

0 commit comments

Comments
 (0)