fix: 修复Ollama模型中没有已下载的模型时,在 MaxKB 添加 Ollama模型报错。#437 (#453)

This commit is contained in:
shaohuzhang1 2024-05-15 11:03:46 +08:00 committed by GitHub
parent 84a770e689
commit 052487a22d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -35,7 +35,7 @@ class OllamaLLMModelCredential(BaseForm, BaseModelCredential):
model_list = OllamaModelProvider.get_base_model_list(model_credential.get('api_base'))
except Exception as e:
raise AppApiException(ValidCode.valid_error.value, "API 域名无效")
exist = [model for model in model_list.get('models') if
exist = [model for model in (model_list.get('models') if model_list.get('models') is not None else []) if
model.get('model') == model_name or model.get('model').replace(":latest", "") == model_name]
if len(exist) == 0:
raise AppApiException(ValidCode.model_not_fount, "模型不存在,请先下载模型")