mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: implement authentication check in image processing model
This commit is contained in:
parent
9c1177759a
commit
e8a52c824a
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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')}])])
|
||||
|
|
|
|||
Loading…
Reference in New Issue