@@ -2,7 +2,6 @@ import { CommandRunner, InquirerService, SubCommand } from 'nest-commander';
22import { exit } from 'node:process' ;
33import { ModelsCliUsecases } from '../usecases/models.cli.usecases' ;
44import { RepoDesignation , listFiles } from '@huggingface/hub' ;
5- import { basename } from 'node:path' ;
65
76@SubCommand ( {
87 name : 'pull' ,
@@ -29,12 +28,9 @@ export class ModelPullCommand extends CommandRunner {
2928 ? undefined
3029 : await this . tryToGetBranches ( input [ 0 ] ) ;
3130
32- if ( ! branches ) {
33- await this . modelsCliUsecases . pullModel ( input [ 0 ] ) ;
34- } else {
35- // if there's metadata.yaml file, we assumed it's a JanHQ model
36- await this . handleJanHqModel ( input [ 0 ] , branches ) ;
37- }
31+ await this . modelsCliUsecases . pullModel (
32+ ! branches ? input [ 0 ] : await this . handleJanHqModel ( input [ 0 ] , branches ) ,
33+ ) ;
3834
3935 console . log ( '\nDownload complete!' ) ;
4036 exit ( 0 ) ;
@@ -83,10 +79,6 @@ export class ModelPullCommand extends CommandRunner {
8379 }
8480
8581 private async handleJanHqModel ( repoName : string , branches : string [ ] ) {
86- const sanitizedRepoName = repoName . trim ( ) . startsWith ( this . janHqModelPrefix )
87- ? repoName
88- : `${ this . janHqModelPrefix } /${ repoName } ` ;
89-
9082 let selectedTag = branches [ 0 ] ;
9183
9284 if ( branches . length > 1 ) {
@@ -98,27 +90,7 @@ export class ModelPullCommand extends CommandRunner {
9890 console . error ( "Can't find model revision." ) ;
9991 exit ( 1 ) ;
10092 }
101-
102- const repo : RepoDesignation = { type : 'model' , name : sanitizedRepoName } ;
103- let ggufUrl : string | undefined = undefined ;
104- for await ( const fileInfo of listFiles ( {
105- repo : repo ,
106- revision : revision ,
107- } ) ) {
108- if ( fileInfo . path . endsWith ( '.gguf' ) ) {
109- ggufUrl = `https://huggingface.co/${ sanitizedRepoName } /resolve/${ revision } /${ fileInfo . path } ` ;
110- break ;
111- }
112- }
113-
114- if ( ! ggufUrl ) {
115- console . error ( "Can't find model file." ) ;
116- exit ( 1 ) ;
117- }
118- console . log ( 'Downloading' , basename ( ggufUrl ) ) ;
119- await this . modelsCliUsecases . pullModelWithExactUrl (
120- `${ sanitizedRepoName } /${ revision } ` ,
121- ggufUrl ,
122- ) ;
93+ // Return parsed model Id
94+ return `${ repoName } :${ revision } ` ;
12395 }
12496}
0 commit comments