mirror of
https://github.com/Tencent/WeKnora.git
synced 2025-11-25 03:15:00 +08:00
将各个判断模型是否可用的逻辑和接口/api/v1/initialization/ollama/models/check的逻辑统一:对于没有指定版本的模型,默认添加":latest",避免误判导致反复调用pull模型接口
This commit is contained in:
@@ -556,11 +556,7 @@ func (h *InitializationHandler) CheckOllamaModels(c *gin.Context) {
|
||||
|
||||
// 检查每个模型是否存在
|
||||
for _, modelName := range req.Models {
|
||||
checkModelName := modelName
|
||||
if !strings.Contains(modelName, ":") {
|
||||
checkModelName = modelName + ":latest"
|
||||
}
|
||||
available, err := h.ollamaService.IsModelAvailable(ctx, checkModelName)
|
||||
available, err := h.ollamaService.IsModelAvailable(ctx, modelName)
|
||||
if err != nil {
|
||||
logger.ErrorWithFields(ctx, err, map[string]interface{}{
|
||||
"model_name": modelName,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user