fix parameter inheritence
parameters are not inherited because they are processed differently from other layer. fix this by explicitly merging the inherited params into the new params. parameter values defined in the new modelfile will override those defined in the inherited modelfile. array lists are replaced instead of appended
This commit is contained in:
parent
e9f6df7dca
commit
06ef90c051
1 changed files with 24 additions and 0 deletions
|
@ -276,6 +276,7 @@ func CreateModel(ctx context.Context, name string, path string, fn func(resp api
|
|||
|
||||
var layers []*LayerReader
|
||||
params := make(map[string][]string)
|
||||
var sourceParams map[string]any
|
||||
embed := EmbeddingParams{fn: fn}
|
||||
for _, c := range commands {
|
||||
log.Printf("[%s] - %s\n", c.Name, c.Args)
|
||||
|
@ -359,6 +360,23 @@ func CreateModel(ctx context.Context, name string, path string, fn func(resp api
|
|||
config.FileType = source.FileType
|
||||
|
||||
for _, l := range mf.Layers {
|
||||
if l.MediaType == "application/vnd.ollama.image.params" {
|
||||
sourceParamsBlobPath, err := GetBlobsPath(l.Digest)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sourceParamsBlob, err := os.Open(sourceParamsBlobPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer sourceParamsBlob.Close()
|
||||
|
||||
if err := json.NewDecoder(sourceParamsBlob).Decode(&sourceParams); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
newLayer, err := GetLayerWithBufferFromLayer(l)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -436,6 +454,12 @@ func CreateModel(ctx context.Context, name string, path string, fn func(resp api
|
|||
return fmt.Errorf("couldn't create params json: %v", err)
|
||||
}
|
||||
|
||||
for k, v := range sourceParams {
|
||||
if _, ok := formattedParams[k]; !ok {
|
||||
formattedParams[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
bts, err := json.Marshal(formattedParams)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in a new issue