From 4378ae4ffaaf71b649efcf87a6a3f77cb923f822 Mon Sep 17 00:00:00 2001 From: frob Date: Sat, 6 Sep 2025 01:27:40 +0200 Subject: [PATCH] parser: don't check the file type of safetensors to prevent false negatives. (#12176) * Don't check the file type of safetensor to prevent false negatives. --------- Co-authored-by: Patrick Devine --- parser/parser.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parser/parser.go b/parser/parser.go index d40a79c290..e080f1bb74 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -246,7 +246,7 @@ func filesForModel(path string) ([]string, error) { for _, match := range matches { if ct, err := detectContentType(match); err != nil { return nil, err - } else if ct != contentType { + } else if len(contentType) > 0 && ct != contentType { return nil, fmt.Errorf("invalid content type: expected %s for %s", ct, match) } } @@ -255,7 +255,8 @@ func filesForModel(path string) ([]string, error) { } var files []string - if st, _ := glob(filepath.Join(path, "*.safetensors"), "application/octet-stream"); len(st) > 0 { + // some safetensors files do not properly match "application/octet-stream", so skip checking their contentType + if st, _ := glob(filepath.Join(path, "*.safetensors"), ""); len(st) > 0 { // safetensors files might be unresolved git lfs references; skip if they are // covers model-x-of-y.safetensors, model.fp32-x-of-y.safetensors, model.safetensors files = append(files, st...)