Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions sdk_v2/js/src/modelVariant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,17 @@ export class ModelVariant implements IModel {
* @param progressCallback - Optional callback to report download progress.
* @throws Error - If progress callback is provided (not implemented).
*/
public download(progressCallback?: (progress: number) => void): void {
public async download(progressCallback?: (progress: number) => void): Promise<void> {
const request = { Params: { Model: this._modelInfo.id } };
if (!progressCallback) {
this.coreInterop.executeCommand("download_model", request);
} else {
throw new Error("Download with progress callback is not implemented yet.");
await this.coreInterop.executeCommandStreaming("download_model", request, (chunk: string) => {
const progress = parseFloat(chunk);
if (!isNaN(progress)) {
progressCallback(progress);
}
});
}
}

Expand Down