Skip to content

Commit 65dbd33

Browse files
prathikrPrathik Rao
andauthored
impl (#441)
Co-authored-by: Prathik Rao <prathikrao@microsoft.com>
1 parent bb4ddc7 commit 65dbd33

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

sdk_v2/js/src/modelVariant.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)