diff --git a/apps/models_provider/impl/aliyun_bai_lian_model_provider/credential/image.py b/apps/models_provider/impl/aliyun_bai_lian_model_provider/credential/image.py index 13f32ebb6..444b1ff2f 100644 --- a/apps/models_provider/impl/aliyun_bai_lian_model_provider/credential/image.py +++ b/apps/models_provider/impl/aliyun_bai_lian_model_provider/credential/image.py @@ -67,9 +67,7 @@ class QwenVLModelCredential(BaseForm, BaseModelCredential): try: model = provider.get_model(model_type, model_name, model_credential, **model_params) - res = model.stream([HumanMessage(content=[{"type": "text", "text": gettext('Hello')}])]) - for chunk in res: - maxkb_logger.info(chunk) + model.check_auth(model_credential.get('api_key')) except Exception as e: traceback.print_exc() if isinstance(e, AppApiException): diff --git a/apps/models_provider/impl/aliyun_bai_lian_model_provider/model/image.py b/apps/models_provider/impl/aliyun_bai_lian_model_provider/model/image.py index 1d63c44c1..a03cccfa3 100644 --- a/apps/models_provider/impl/aliyun_bai_lian_model_provider/model/image.py +++ b/apps/models_provider/impl/aliyun_bai_lian_model_provider/model/image.py @@ -2,6 +2,9 @@ from typing import Dict +from langchain_community.chat_models import ChatTongyi +from langchain_core.messages import HumanMessage +from django.utils.translation import gettext from models_provider.base_model_provider import MaxKBBaseModel from models_provider.impl.base_chat_open_ai import BaseChatOpenAI @@ -25,3 +28,7 @@ class QwenVLChatModel(MaxKBBaseModel, BaseChatOpenAI): extra_body=optional_params ) return chat_tong_yi + + def check_auth(self, api_key): + chat = ChatTongyi(api_key=api_key, model_name='qwen-max') + chat.invoke([HumanMessage([{"type": "text", "text": gettext('Hello')}])])