@@ -28,9 +28,9 @@ func FromGGUF(path string) (*Builder, error) {
2828 }, nil
2929}
3030
31- // FromSafetensorsWithConfig returns a *Builder that builds model artifacts from safetensors files with a config archive
32- func FromSafetensorsWithConfig (safetensorsPaths []string , configArchivePath string ) (* Builder , error ) {
33- mdl , err := safetensors .NewModelWithConfigArchive (safetensorsPaths , configArchivePath )
31+ // FromSafetensors returns a *Builder that builds model artifacts from safetensors files
32+ func FromSafetensors (safetensorsPaths []string ) (* Builder , error ) {
33+ mdl , err := safetensors .NewModel (safetensorsPaths )
3434 if err != nil {
3535 return nil , err
3636 }
@@ -80,6 +80,19 @@ func (b *Builder) WithChatTemplateFile(path string) (*Builder, error) {
8080
8181// WithConfigArchive adds a config archive (tar) file to the artifact
8282func (b * Builder ) WithConfigArchive (path string ) (* Builder , error ) {
83+ // Check if config archive already exists
84+ layers , err := b .model .Layers ()
85+ if err != nil {
86+ return nil , fmt .Errorf ("get model layers: %w" , err )
87+ }
88+
89+ for _ , layer := range layers {
90+ mediaType , err := layer .MediaType ()
91+ if err == nil && mediaType == types .MediaTypeVLLMConfigArchive {
92+ return nil , fmt .Errorf ("model already has a config archive layer" )
93+ }
94+ }
95+
8396 configLayer , err := partial .NewLayer (path , types .MediaTypeVLLMConfigArchive )
8497 if err != nil {
8598 return nil , fmt .Errorf ("config archive layer from %q: %w" , path , err )
0 commit comments