File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,12 +67,17 @@ export class ModelVariant implements IModel {
6767 * @param progressCallback - Optional callback to report download progress.
6868 * @throws Error - If progress callback is provided (not implemented).
6969 */
70- public download ( progressCallback ?: ( progress : number ) => void ) : void {
70+ public async download ( progressCallback ?: ( progress : number ) => void ) : Promise < void > {
7171 const request = { Params : { Model : this . _modelInfo . id } } ;
7272 if ( ! progressCallback ) {
7373 this . coreInterop . executeCommand ( "download_model" , request ) ;
7474 } else {
75- throw new Error ( "Download with progress callback is not implemented yet." ) ;
75+ await this . coreInterop . executeCommandStreaming ( "download_model" , request , ( chunk : string ) => {
76+ const progress = parseFloat ( chunk ) ;
77+ if ( ! isNaN ( progress ) ) {
78+ progressCallback ( progress ) ;
79+ }
80+ } ) ;
7681 }
7782 }
7883
You can’t perform that action at this time.
0 commit comments