File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -189,12 +189,12 @@ export async function parseSafetensorsMetadata(
189189 params : {
190190 /** Only models are supported */
191191 repo : RepoDesignation ;
192+ path ?: string ;
192193 /**
193194 * Will include SafetensorsParseFromRepo["parameterCount"], an object containing the number of parameters for each DType
194195 *
195196 * @default false
196197 */
197- path ?: string ;
198198 computeParametersCount ?: boolean ;
199199 hubUrl ?: string ;
200200 revision ?: string ;
@@ -223,7 +223,10 @@ export async function parseSafetensorsMetadata(
223223 throw new TypeError ( "Only model repos should contain safetensors files." ) ;
224224 }
225225
226- if ( RE_SAFETENSORS_FILE . test ( params . path ?? "" ) || ( await fileExists ( { ...params , path : SAFETENSORS_FILE } ) ) ) {
226+ if (
227+ ( params . path && RE_SAFETENSORS_FILE . test ( params . path ) ) ||
228+ ( await fileExists ( { ...params , path : SAFETENSORS_FILE } ) )
229+ ) {
227230 const header = await parseSingleFile ( params . path ?? SAFETENSORS_FILE , params ) ;
228231 return {
229232 sharded : false ,
@@ -233,7 +236,7 @@ export async function parseSafetensorsMetadata(
233236 } ) ,
234237 } ;
235238 } else if (
236- RE_SAFETENSORS_INDEX_FILE . test ( params . path ?? "" ) ||
239+ ( params . path && RE_SAFETENSORS_INDEX_FILE . test ( params . path ) ) ||
237240 ( await fileExists ( { ...params , path : SAFETENSORS_INDEX_FILE } ) )
238241 ) {
239242 const { index, headers } = await parseShardedIndex ( params . path ?? SAFETENSORS_INDEX_FILE , params ) ;
You can’t perform that action at this time.
0 commit comments