refactor: Add log records for image understanding
--bug=1057568 --user=王孝刚 【模型管理】阿里云百炼视觉模型输入错误的基础模型可正常创建 https://www.tapd.cn/62980211/s/1719185
This commit is contained in:
parent
37ac79dc5a
commit
0886459bad
@ -15,6 +15,7 @@ from langchain_core.messages import HumanMessage
|
||||
from common import forms
|
||||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm
|
||||
from common.utils.logger import maxkb_logger
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
|
||||
@ -48,6 +49,8 @@ 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)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
|
||||
@ -8,6 +8,7 @@ from langchain_core.messages import HumanMessage
|
||||
from common import forms
|
||||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from common.utils.logger import maxkb_logger
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
|
||||
@ -31,6 +32,8 @@ class AnthropicImageModelCredential(BaseForm, BaseModelCredential):
|
||||
try:
|
||||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
res = model.stream([HumanMessage(content=[{"type": "text", "text": gettext("Hello")}])])
|
||||
for chunk in res:
|
||||
maxkb_logger.info(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
|
||||
@ -9,6 +9,7 @@ from langchain_core.messages import HumanMessage
|
||||
from common import forms
|
||||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from common.utils.logger import maxkb_logger
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
||||
@ -38,6 +39,8 @@ class AzureOpenAIImageModelCredential(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)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
|
||||
@ -8,6 +8,7 @@ from langchain_core.messages import HumanMessage
|
||||
from common import forms
|
||||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from common.utils.logger import maxkb_logger
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
|
||||
@ -30,6 +31,8 @@ class GeminiImageModelCredential(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)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
|
||||
@ -9,6 +9,7 @@ from langchain_core.messages import HumanMessage
|
||||
from common import forms
|
||||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from common.utils.logger import maxkb_logger
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
||||
@ -33,6 +34,8 @@ class OpenAIImageModelCredential(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)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
|
||||
@ -9,6 +9,7 @@ from langchain_core.messages import HumanMessage
|
||||
from common import forms
|
||||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from common.utils.logger import maxkb_logger
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
||||
@ -33,6 +34,8 @@ class SiliconCloudImageModelCredential(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)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
|
||||
@ -15,6 +15,7 @@ from langchain_core.messages import HumanMessage
|
||||
from common import forms
|
||||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from common.utils.logger import maxkb_logger
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
|
||||
@ -35,6 +36,8 @@ class TencentVisionModelCredential(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)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
|
||||
@ -8,6 +8,7 @@ from langchain_core.messages import HumanMessage
|
||||
from common import forms
|
||||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from common.utils.logger import maxkb_logger
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
class VllmImageModelCredential(BaseForm, BaseModelCredential):
|
||||
@ -30,6 +31,8 @@ class VllmImageModelCredential(BaseForm, BaseModelCredential):
|
||||
try:
|
||||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
res = model.stream([HumanMessage(content=[{"type": "text", "text": "你好"}])])
|
||||
for chunk in res:
|
||||
maxkb_logger.info(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
|
||||
@ -8,6 +8,7 @@ from langchain_core.messages import HumanMessage
|
||||
from common import forms
|
||||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from common.utils.logger import maxkb_logger
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
class VolcanicEngineImageModelCredential(BaseForm, BaseModelCredential):
|
||||
@ -30,6 +31,8 @@ class VolcanicEngineImageModelCredential(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)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
|
||||
@ -7,6 +7,7 @@ from langchain_core.messages import HumanMessage
|
||||
from common import forms
|
||||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from common.utils.logger import maxkb_logger
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
|
||||
@ -30,6 +31,8 @@ class XinferenceImageModelCredential(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)
|
||||
except Exception as e:
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
|
||||
@ -8,6 +8,7 @@ from langchain_core.messages import HumanMessage
|
||||
from common import forms
|
||||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from common.utils.logger import maxkb_logger
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
class ZhiPuImageModelCredential(BaseForm, BaseModelCredential):
|
||||
@ -29,6 +30,8 @@ class ZhiPuImageModelCredential(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)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user