@@ -16,6 +16,7 @@ import (
16
16
tea "github.com/charmbracelet/bubbletea"
17
17
"github.com/charmbracelet/lipgloss"
18
18
"github.com/ollama/ollama/api"
19
+ ollama_model "github.com/ollama/ollama/types/model"
19
20
"github.com/sammcj/gollama/config"
20
21
"github.com/sammcj/gollama/logging"
21
22
"github.com/sammcj/gollama/styles"
@@ -1052,22 +1053,24 @@ func linkModel(modelName, lmStudioModelsDir string, noCleanup bool, dryRun bool,
1052
1053
if err != nil {
1053
1054
return "" , fmt .Errorf ("error getting model files for %s: %v" , modelName , err )
1054
1055
}
1056
+ fullModelName := ollama_model .ParseName (modelName )
1055
1057
1056
- // Extract author from model name (e.g., "fleo/tiny-r1-32b-preview:latest" -> "fleo")
1057
- parts := strings .Split (modelName , ":" )
1058
- author := "unknown"
1059
- if len (parts ) > 1 && strings .Contains (parts [0 ], "/" ) {
1060
- authorParts := strings .Split (parts [0 ], "/" )
1061
- author = authorParts [0 ]
1062
- } else if strings .Contains (modelName , "/" ) {
1063
- authorParts := strings .Split (modelName , "/" )
1064
- author = authorParts [0 ]
1058
+ // Extract author from model name, e.g.:
1059
+ // * "fleo/tiny-r1-32b-preview:latest" -> "registry.ollama.ai/fleo/tiny-r1-32b-preview" -> "fleo"
1060
+ // * "huggingface.co/fleo/tiny-r1-32b-preview" -> "fleo"
1061
+ // * "tiny-r1-32b-preview:latest" -> "registry.ollama.ai/library/tiny-r1-32b-preview" -> "registry.ollama.ai" (Use host as author if the namespace is default `library`)
1062
+ author := fullModelName .Namespace
1063
+ if author == ollama_model .DefaultName ().Namespace {
1064
+ author = fullModelName .Host
1065
1065
}
1066
1066
1067
1067
// Create a clean model name for the file
1068
- lmStudioModelName := strings .ReplaceAll (strings .ReplaceAll (modelName , ":" , "-" ), "_" , "-" )
1069
- lmStudioModelName = strings .ReplaceAll (lmStudioModelName , "/" , "-" )
1070
- lmStudioModelDir := filepath .Join (lmStudioModelsDir , author , lmStudioModelName + "-GGUF" )
1068
+ // * model tag is appended to the model name if it's not the default `latest` tag
1069
+ lmStudioModelName := fullModelName .Model
1070
+ if fullModelName .Tag != ollama_model .DefaultName ().Tag {
1071
+ lmStudioModelName += "-" + fullModelName .Tag
1072
+ }
1073
+ lmStudioModelDir := filepath .Join (lmStudioModelsDir , author , lmStudioModelName )
1071
1074
1072
1075
// Check if the main model path is a valid file
1073
1076
fileInfo , err := os .Stat (modelFiles .MainModel )
0 commit comments