feat: implement authentication check in image processing model
parent
9c1177759a
commit
e8a52c824a
|
|
@ -67,9 +67,7 @@ class QwenVLModelCredential(BaseForm, BaseModelCredential):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||||
res = model.stream([HumanMessage(content=[{"type": "text", "text": gettext('Hello')}])])
|
model.check_auth(model_credential.get('api_key'))
|
||||||
for chunk in res:
|
|
||||||
maxkb_logger.info(chunk)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
if isinstance(e, AppApiException):
|
if isinstance(e, AppApiException):
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
from typing import Dict
|
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.base_model_provider import MaxKBBaseModel
|
||||||
from models_provider.impl.base_chat_open_ai import BaseChatOpenAI
|
from models_provider.impl.base_chat_open_ai import BaseChatOpenAI
|
||||||
|
|
||||||
|
|
@ -25,3 +28,7 @@ class QwenVLChatModel(MaxKBBaseModel, BaseChatOpenAI):
|
||||||
extra_body=optional_params
|
extra_body=optional_params
|
||||||
)
|
)
|
||||||
return chat_tong_yi
|
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