@@ -12,7 +12,7 @@ import { rm } from 'fs/promises';
1212import { exec } from 'child_process' ;
1313import { appPath } from '@/utils/app-path' ;
1414import {
15- CORTEX_ONNX_ENGINE_RELEASES_URL ,
15+ CORTEX_ENGINE_RELEASES_URL ,
1616 CORTEX_RELEASES_URL ,
1717 CUDA_DOWNLOAD_URL ,
1818} from '@/infrastructure/constants/cortex' ;
@@ -70,13 +70,13 @@ export class InitCliUsecases {
7070 )
7171 await this . installLlamaCppEngine ( options , version ) ;
7272
73- if ( engine === 'cortex.onnx' && process . platform === 'win32' )
74- await this . installONNXEngine ( ) ;
75- else if ( engine === 'cortex.onnx' && process . platform !== 'win32' ) {
73+ if ( engine === 'cortex.onnx' && process . platform !== 'win32' ) {
7674 console . error ( 'The ONNX engine does not support this OS yet.' ) ;
7775 process . exit ( 1 ) ;
7876 }
7977
78+ if ( engine !== 'cortex.llamacpp' ) await this . installAcceleratedEngine ( ) ;
79+
8080 configs . initialized = true ;
8181 await this . fileManagerService . writeConfigFile ( configs ) ;
8282 } ;
@@ -305,17 +305,17 @@ export class InitCliUsecases {
305305 } ;
306306
307307 /**
308- * Download and install ONNX engine
308+ * Download and install accelerated engine
309309 * @param version
310310 * @param engineFileName
311311 */
312- private async installONNXEngine (
312+ private async installAcceleratedEngine (
313313 version : string = 'latest' ,
314- engineFileName : string = 'windows-amd64 ' ,
314+ engine : string = 'cortex.onnx ' ,
315315 ) {
316316 const res = await firstValueFrom (
317317 this . httpService . get (
318- CORTEX_ONNX_ENGINE_RELEASES_URL +
318+ CORTEX_ENGINE_RELEASES_URL ( engine ) +
319319 `${ version === 'latest' ? '/latest' : '' } ` ,
320320 {
321321 headers : {
@@ -338,15 +338,17 @@ export class InitCliUsecases {
338338 ) ;
339339 }
340340 const toDownloadAsset = release . assets . find ( ( s : any ) =>
341- s . name . includes ( engineFileName ) ,
341+ s . name . includes ( process . platform === 'win32' ? 'windows' : 'linux' ) ,
342342 ) ;
343343
344344 if ( ! toDownloadAsset ) {
345- console . log ( `Could not find engine file ${ engineFileName } ` ) ;
345+ console . log (
346+ `Could not find engine file for platform ${ process . platform } ` ,
347+ ) ;
346348 exit ( 1 ) ;
347349 }
348350
349- console . log ( `Downloading ONNX engine file ${ engineFileName } ` ) ;
351+ console . log ( `Downloading ONNX engine file ${ toDownloadAsset . name } ` ) ;
350352 const dataFolderPath = await this . fileManagerService . getDataFolderPath ( ) ;
351353 const engineDir = join ( dataFolderPath , 'cortex-cpp' ) ;
352354
@@ -397,7 +399,7 @@ export class InitCliUsecases {
397399 await rm ( destination , { force : true } ) ;
398400
399401 // Copy the additional files to the cortex-cpp directory
400- for ( const file of readdirSync ( join ( engineDir , 'engines' , 'cortex.onnx' ) ) ) {
402+ for ( const file of readdirSync ( join ( engineDir , 'engines' , engine ) ) ) {
401403 if ( file !== 'engine.dll' ) {
402404 await cpSync (
403405 join ( engineDir , 'engines' , 'cortex.onnx' , file ) ,
0 commit comments