File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export { GGUF_QUANT_DESCRIPTIONS } from "./quant-descriptions";
9
9
10
10
export const RE_GGUF_FILE = / \. g g u f $ / ;
11
11
export const RE_GGUF_SHARD_FILE = / ^ (?< prefix > .* ?) - (?< shard > \d { 5 } ) - o f - (?< total > \d { 5 } ) \. g g u f $ / ;
12
+ const PARALLEL_DOWNLOADS = 20 ;
12
13
13
14
export interface GgufShardFileInfo {
14
15
prefix : string ;
@@ -401,8 +402,13 @@ export async function ggufAllShards(
401
402
*/
402
403
fetch ?: typeof fetch ;
403
404
additionalFetchHeaders ?: Record < string , string > ;
405
+ parallelDownloads ?: number ;
404
406
}
405
407
) : Promise < { shards : GGUFParseOutput [ ] ; parameterCount : number } > {
408
+ const parallelDownloads = params ?. parallelDownloads ?? PARALLEL_DOWNLOADS ;
409
+ if ( parallelDownloads < 1 ) {
410
+ throw new TypeError ( "parallelDownloads must be greater than 0" ) ;
411
+ }
406
412
const ggufShardFileInfo = parseGgufShardFilename ( url ) ;
407
413
if ( ggufShardFileInfo ) {
408
414
const total = parseInt ( ggufShardFileInfo . total ) ;
@@ -413,10 +419,9 @@ export async function ggufAllShards(
413
419
urls . push ( `${ prefix } -${ shardIdx . toString ( ) . padStart ( 5 , "0" ) } -of-${ total . toString ( ) . padStart ( 5 , "0" ) } .gguf` ) ;
414
420
}
415
421
416
- const PARALLEL_DOWNLOADS = 20 ;
417
422
const shards = await promisesQueue (
418
423
urls . map ( ( shardUrl ) => ( ) => gguf ( shardUrl , { ...params , computeParametersCount : true } ) ) ,
419
- PARALLEL_DOWNLOADS
424
+ parallelDownloads
420
425
) ;
421
426
return {
422
427
shards,
You can’t perform that action at this time.
0 commit comments