mirror of
https://github.com/ollama/ollama.git
synced 2025-05-11 18:36:41 +02:00
convert: fix parse functions
This commit is contained in:
parent
eafc607abb
commit
d8e2664c33
2 changed files with 21 additions and 15 deletions
|
@ -220,19 +220,22 @@ func parseVocabularyFromTokenizer(fsys fs.FS) (*Vocabulary, error) {
|
|||
}
|
||||
|
||||
func parseVocabulary(fsys fs.FS) (*Vocabulary, error) {
|
||||
patterns := map[string]func(fs.FS) (*Vocabulary, error){
|
||||
"tokenizer.model": parseSentencePiece,
|
||||
"tokenizer.json": parseVocabularyFromTokenizer,
|
||||
patterns := []struct {
|
||||
Pattern string
|
||||
Func func(fs.FS) (*Vocabulary, error)
|
||||
}{
|
||||
{"tokenizer.model", parseSentencePiece},
|
||||
{"tokenizer.json", parseVocabularyFromTokenizer},
|
||||
}
|
||||
|
||||
for pattern, parseFn := range patterns {
|
||||
if _, err := fs.Stat(fsys, pattern); errors.Is(err, os.ErrNotExist) {
|
||||
for _, pattern := range patterns {
|
||||
if _, err := fs.Stat(fsys, pattern.Pattern); errors.Is(err, os.ErrNotExist) {
|
||||
continue
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return parseFn(fsys)
|
||||
return pattern.Func(fsys)
|
||||
}
|
||||
|
||||
return nil, errors.New("unknown tensor format")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue