将各个判断模型是否可用的逻辑和接口/api/v1/initialization/ollama/models/check的逻辑统一:对于没有指定版本的模型,默认添加":latest",避免误判导致反复调用pull模型接口

This commit is contained in:
fuyaozong
2025-11-12 18:36:21 +08:00
committed by lyingbug
parent 07c3453e1a
commit ef69e2aed5
2 changed files with 7 additions and 6 deletions
+6 -1
View File
@@ -107,9 +107,14 @@ func (s *OllamaService) IsModelAvailable(ctx context.Context, modelName string)
return false, fmt.Errorf("failed to get model list: %w", err)
}
// If no version is specified for the model, add ":latest" by default
checkModelName := modelName
if !strings.Contains(modelName, ":") {
checkModelName = modelName + ":latest"
}
// Check if model is in the list
for _, model := range listResp.Models {
if model.Name == modelName {
if model.Name == checkModelName {
return true, nil
}
}