From 0886459bad315e5bb621c7b81b86838351ef9a23 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Thu, 26 Jun 2025 16:57:56 +0800 Subject: [PATCH] refactor: Add log records for image understanding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1057568 --user=王孝刚 【模型管理】阿里云百炼视觉模型输入错误的基础模型可正常创建 https://www.tapd.cn/62980211/s/1719185 --- .../impl/aliyun_bai_lian_model_provider/credential/image.py | 3 +++ .../impl/anthropic_model_provider/credential/image.py | 3 +++ .../impl/azure_model_provider/credential/image.py | 3 +++ .../impl/gemini_model_provider/credential/image.py | 3 +++ .../impl/openai_model_provider/credential/image.py | 3 +++ .../impl/siliconCloud_model_provider/credential/image.py | 3 +++ .../impl/tencent_model_provider/credential/image.py | 3 +++ .../impl/vllm_model_provider/credential/image.py | 3 +++ .../impl/volcanic_engine_model_provider/credential/image.py | 3 +++ .../impl/xinference_model_provider/credential/image.py | 3 +++ .../impl/zhipu_model_provider/credential/image.py | 3 +++ 11 files changed, 33 insertions(+) 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 cf91d1622..e5ab576b7 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 @@ -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): diff --git a/apps/models_provider/impl/anthropic_model_provider/credential/image.py b/apps/models_provider/impl/anthropic_model_provider/credential/image.py index 1d23e3688..1107b08f2 100644 --- a/apps/models_provider/impl/anthropic_model_provider/credential/image.py +++ b/apps/models_provider/impl/anthropic_model_provider/credential/image.py @@ -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): diff --git a/apps/models_provider/impl/azure_model_provider/credential/image.py b/apps/models_provider/impl/azure_model_provider/credential/image.py index e0322e043..0c955badf 100644 --- a/apps/models_provider/impl/azure_model_provider/credential/image.py +++ b/apps/models_provider/impl/azure_model_provider/credential/image.py @@ -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): diff --git a/apps/models_provider/impl/gemini_model_provider/credential/image.py b/apps/models_provider/impl/gemini_model_provider/credential/image.py index a83551bca..8fb6fa0ff 100644 --- a/apps/models_provider/impl/gemini_model_provider/credential/image.py +++ b/apps/models_provider/impl/gemini_model_provider/credential/image.py @@ -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): diff --git a/apps/models_provider/impl/openai_model_provider/credential/image.py b/apps/models_provider/impl/openai_model_provider/credential/image.py index 85519a960..e31102a4f 100644 --- a/apps/models_provider/impl/openai_model_provider/credential/image.py +++ b/apps/models_provider/impl/openai_model_provider/credential/image.py @@ -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): diff --git a/apps/models_provider/impl/siliconCloud_model_provider/credential/image.py b/apps/models_provider/impl/siliconCloud_model_provider/credential/image.py index 6aefdf50c..22d072326 100644 --- a/apps/models_provider/impl/siliconCloud_model_provider/credential/image.py +++ b/apps/models_provider/impl/siliconCloud_model_provider/credential/image.py @@ -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): diff --git a/apps/models_provider/impl/tencent_model_provider/credential/image.py b/apps/models_provider/impl/tencent_model_provider/credential/image.py index 4ad6fa83b..81376cd83 100644 --- a/apps/models_provider/impl/tencent_model_provider/credential/image.py +++ b/apps/models_provider/impl/tencent_model_provider/credential/image.py @@ -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): diff --git a/apps/models_provider/impl/vllm_model_provider/credential/image.py b/apps/models_provider/impl/vllm_model_provider/credential/image.py index bcafece89..d1fd5dae5 100644 --- a/apps/models_provider/impl/vllm_model_provider/credential/image.py +++ b/apps/models_provider/impl/vllm_model_provider/credential/image.py @@ -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): diff --git a/apps/models_provider/impl/volcanic_engine_model_provider/credential/image.py b/apps/models_provider/impl/volcanic_engine_model_provider/credential/image.py index 2670719c3..2c55cd68b 100644 --- a/apps/models_provider/impl/volcanic_engine_model_provider/credential/image.py +++ b/apps/models_provider/impl/volcanic_engine_model_provider/credential/image.py @@ -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): diff --git a/apps/models_provider/impl/xinference_model_provider/credential/image.py b/apps/models_provider/impl/xinference_model_provider/credential/image.py index e9ebbf7e2..20aec6bf6 100644 --- a/apps/models_provider/impl/xinference_model_provider/credential/image.py +++ b/apps/models_provider/impl/xinference_model_provider/credential/image.py @@ -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 diff --git a/apps/models_provider/impl/zhipu_model_provider/credential/image.py b/apps/models_provider/impl/zhipu_model_provider/credential/image.py index 5e28ddc27..7b192bf24 100644 --- a/apps/models_provider/impl/zhipu_model_provider/credential/image.py +++ b/apps/models_provider/impl/zhipu_model_provider/credential/image.py @@ -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):