mirror of
https://github.com/dogkeeper886/ollama37.git
synced 2025-12-10 07:46:59 +00:00
detect chat template from KV
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
"github.com/ollama/ollama/format"
|
||||
"github.com/ollama/ollama/llm"
|
||||
"github.com/ollama/ollama/parser"
|
||||
"github.com/ollama/ollama/templates"
|
||||
"github.com/ollama/ollama/types/errtypes"
|
||||
"github.com/ollama/ollama/types/model"
|
||||
"github.com/ollama/ollama/version"
|
||||
@@ -434,6 +435,21 @@ func CreateModel(ctx context.Context, name model.Name, modelFileDir, quantizatio
|
||||
config.ModelType = cmp.Or(config.ModelType, format.HumanNumber(baseLayer.GGML.KV().ParameterCount()))
|
||||
config.FileType = cmp.Or(config.FileType, baseLayer.GGML.KV().FileType().String())
|
||||
config.ModelFamilies = append(config.ModelFamilies, baseLayer.GGML.KV().Architecture())
|
||||
|
||||
if s := baseLayer.GGML.KV().ChatTemplate(); s != "" {
|
||||
t, err := templates.NamedTemplate(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
layer, err := NewLayer(t.Reader(), "application/vnd.ollama.image.template")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
layer.status = fmt.Sprintf("using autodetected template %s", t.Name)
|
||||
layers = append(layers, layer)
|
||||
}
|
||||
}
|
||||
|
||||
layers = append(layers, baseLayer.Layer)
|
||||
|
||||
Reference in New Issue
Block a user