@@ -105,24 +105,48 @@ func CreateHandler(cmd *cobra.Command, args []string) error {
105
105
106
106
zf := zip .NewWriter (tf )
107
107
108
- files , err := filepath .Glob (filepath .Join (path , "model-*.safetensors" ))
108
+ files := []string {}
109
+
110
+ tfiles , err := filepath .Glob (filepath .Join (path , "pytorch_model-*.bin" ))
109
111
if err != nil {
110
112
return err
113
+ } else if len (tfiles ) == 0 {
114
+ tfiles , err = filepath .Glob (filepath .Join (path , "model-*.safetensors" ))
115
+ if err != nil {
116
+ return err
117
+ }
111
118
}
112
119
120
+ files = append (files , tfiles ... )
121
+
113
122
if len (files ) == 0 {
114
- return fmt .Errorf ("no safetensors files were found in '%s'" , path )
123
+ return fmt .Errorf ("no models were found in '%s'" , path )
115
124
}
116
125
117
- // add the safetensor config file + tokenizer
126
+ // add the safetensor/torch config file + tokenizer
118
127
files = append (files , filepath .Join (path , "config.json" ))
128
+ files = append (files , filepath .Join (path , "params.json" ))
119
129
files = append (files , filepath .Join (path , "added_tokens.json" ))
120
130
files = append (files , filepath .Join (path , "tokenizer.model" ))
121
131
122
132
for _ , fn := range files {
123
133
f , err := os .Open (fn )
124
- if os .IsNotExist (err ) && strings .HasSuffix (fn , "added_tokens.json" ) {
125
- continue
134
+
135
+ // just skip whatever files aren't there
136
+ if os .IsNotExist (err ) {
137
+ if strings .HasSuffix (fn , "tokenizer.model" ) {
138
+ // try the parent dir before giving up
139
+ parentDir := filepath .Dir (path )
140
+ newFn := filepath .Join (parentDir , "tokenizer.model" )
141
+ f , err = os .Open (newFn )
142
+ if os .IsNotExist (err ) {
143
+ continue
144
+ } else if err != nil {
145
+ return err
146
+ }
147
+ } else {
148
+ continue
149
+ }
126
150
} else if err != nil {
127
151
return err
128
152
}
0 commit comments