mirror of
https://github.com/ollama/ollama.git
synced 2025-05-11 18:36:41 +02:00
Fix absolute path names + gguf detection (#8428)
This commit is contained in:
parent
61676fb506
commit
2539f2dbf9
4 changed files with 217 additions and 28 deletions
|
@ -178,12 +178,37 @@ func convertModelFromFiles(files map[string]string, baseLayers []*layerGGML, isA
|
|||
}
|
||||
|
||||
func detectModelTypeFromFiles(files map[string]string) string {
|
||||
// todo make this more robust by actually introspecting the files
|
||||
for fn := range files {
|
||||
if strings.HasSuffix(fn, ".safetensors") {
|
||||
return "safetensors"
|
||||
} else if strings.HasSuffix(fn, ".bin") || strings.HasSuffix(fn, ".gguf") {
|
||||
} else if strings.HasSuffix(fn, ".gguf") {
|
||||
return "gguf"
|
||||
} else {
|
||||
// try to see if we can find a gguf file even without the file extension
|
||||
blobPath, err := GetBlobsPath(files[fn])
|
||||
if err != nil {
|
||||
slog.Error("error getting blobs path", "file", fn)
|
||||
return ""
|
||||
}
|
||||
|
||||
f, err := os.Open(blobPath)
|
||||
if err != nil {
|
||||
slog.Error("error reading file", "error", err)
|
||||
return ""
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
buf := make([]byte, 4)
|
||||
_, err = f.Read(buf)
|
||||
if err != nil {
|
||||
slog.Error("error reading file", "error", err)
|
||||
return ""
|
||||
}
|
||||
|
||||
ct := llm.DetectGGMLType(buf)
|
||||
if ct == "gguf" {
|
||||
return "gguf"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue