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";
99
1010export const RE_GGUF_FILE = / \. g g u f $ / ;
1111export const RE_GGUF_SHARD_FILE = / ^ (?< prefix > .* ?) - (?< shard > \d { 5 } ) - o f - (?< total > \d { 5 } ) \. g g u f $ / ;
12+ const PARALLEL_DOWNLOADS = 20 ;
1213
1314export interface GgufShardFileInfo {
1415 prefix : string ;
@@ -401,8 +402,13 @@ export async function ggufAllShards(
401402 */
402403 fetch ?: typeof fetch ;
403404 additionalFetchHeaders ?: Record < string , string > ;
405+ parallelDownloads ?: number ;
404406 }
405407) : 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+ }
406412 const ggufShardFileInfo = parseGgufShardFilename ( url ) ;
407413 if ( ggufShardFileInfo ) {
408414 const total = parseInt ( ggufShardFileInfo . total ) ;
@@ -413,10 +419,9 @@ export async function ggufAllShards(
413419 urls . push ( `${ prefix } -${ shardIdx . toString ( ) . padStart ( 5 , "0" ) } -of-${ total . toString ( ) . padStart ( 5 , "0" ) } .gguf` ) ;
414420 }
415421
416- const PARALLEL_DOWNLOADS = 20 ;
417422 const shards = await promisesQueue (
418423 urls . map ( ( shardUrl ) => ( ) => gguf ( shardUrl , { ...params , computeParametersCount : true } ) ) ,
419- PARALLEL_DOWNLOADS
424+ parallelDownloads
420425 ) ;
421426 return {
422427 shards,
You can’t perform that action at this time.
0 commit comments