Skip to content

Commit 0886459

Browse files
committed
refactor: Add log records for image understanding
--bug=1057568 --user=王孝刚 【模型管理】阿里云百炼视觉模型输入错误的基础模型可正常创建 https://www.tapd.cn/62980211/s/1719185
1 parent 37ac79d commit 0886459

File tree

11 files changed

+33
-0
lines changed
  • apps/models_provider/impl
    • aliyun_bai_lian_model_provider/credential
    • anthropic_model_provider/credential
    • azure_model_provider/credential
    • gemini_model_provider/credential
    • openai_model_provider/credential
    • siliconCloud_model_provider/credential
    • tencent_model_provider/credential
    • vllm_model_provider/credential
    • volcanic_engine_model_provider/credential
    • xinference_model_provider/credential
    • zhipu_model_provider/credential

11 files changed

+33
-0
lines changed

apps/models_provider/impl/aliyun_bai_lian_model_provider/credential/image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from common import forms
1616
from common.exception.app_exception import AppApiException
1717
from common.forms import BaseForm
18+
from common.utils.logger import maxkb_logger
1819
from models_provider.base_model_provider import BaseModelCredential, ValidCode
1920

2021

@@ -48,6 +49,8 @@ def is_valid(
4849
try:
4950
model = provider.get_model(model_type, model_name, model_credential, **model_params)
5051
res = model.stream([HumanMessage(content=[{"type": "text", "text": gettext('Hello')}])])
52+
for chunk in res:
53+
maxkb_logger.info(chunk)
5154
except Exception as e:
5255
traceback.print_exc()
5356
if isinstance(e, AppApiException):

apps/models_provider/impl/anthropic_model_provider/credential/image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from common import forms
99
from common.exception.app_exception import AppApiException
1010
from common.forms import BaseForm, TooltipLabel
11+
from common.utils.logger import maxkb_logger
1112
from models_provider.base_model_provider import BaseModelCredential, ValidCode
1213

1314

@@ -31,6 +32,8 @@ def is_valid(self, model_type: str, model_name, model_credential: Dict[str, obje
3132
try:
3233
model = provider.get_model(model_type, model_name, model_credential)
3334
res = model.stream([HumanMessage(content=[{"type": "text", "text": gettext("Hello")}])])
35+
for chunk in res:
36+
maxkb_logger.info(chunk)
3437
except Exception as e:
3538
traceback.print_exc()
3639
if isinstance(e, AppApiException):

apps/models_provider/impl/azure_model_provider/credential/image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from common import forms
1010
from common.exception.app_exception import AppApiException
1111
from common.forms import BaseForm, TooltipLabel
12+
from common.utils.logger import maxkb_logger
1213
from models_provider.base_model_provider import BaseModelCredential, ValidCode
1314
from django.utils.translation import gettext_lazy as _, gettext
1415

@@ -38,6 +39,8 @@ def is_valid(self, model_type: str, model_name, model_credential: Dict[str, obje
3839
try:
3940
model = provider.get_model(model_type, model_name, model_credential, **model_params)
4041
res = model.stream([HumanMessage(content=[{"type": "text", "text": gettext('Hello')}])])
42+
for chunk in res:
43+
maxkb_logger.info(chunk)
4144
except Exception as e:
4245
traceback.print_exc()
4346
if isinstance(e, AppApiException):

apps/models_provider/impl/gemini_model_provider/credential/image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from common import forms
99
from common.exception.app_exception import AppApiException
1010
from common.forms import BaseForm, TooltipLabel
11+
from common.utils.logger import maxkb_logger
1112
from models_provider.base_model_provider import BaseModelCredential, ValidCode
1213

1314

@@ -30,6 +31,8 @@ def is_valid(self, model_type: str, model_name, model_credential: Dict[str, obje
3031
try:
3132
model = provider.get_model(model_type, model_name, model_credential, **model_params)
3233
res = model.stream([HumanMessage(content=[{"type": "text", "text": gettext('Hello')}])])
34+
for chunk in res:
35+
maxkb_logger.info(chunk)
3336
except Exception as e:
3437
traceback.print_exc()
3538
if isinstance(e, AppApiException):

apps/models_provider/impl/openai_model_provider/credential/image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from common import forms
1010
from common.exception.app_exception import AppApiException
1111
from common.forms import BaseForm, TooltipLabel
12+
from common.utils.logger import maxkb_logger
1213
from models_provider.base_model_provider import BaseModelCredential, ValidCode
1314
from django.utils.translation import gettext_lazy as _, gettext
1415

@@ -33,6 +34,8 @@ def is_valid(self, model_type: str, model_name, model_credential: Dict[str, obje
3334
try:
3435
model = provider.get_model(model_type, model_name, model_credential, **model_params)
3536
res = model.stream([HumanMessage(content=[{"type": "text", "text": gettext('Hello')}])])
37+
for chunk in res:
38+
maxkb_logger.info(chunk)
3639
except Exception as e:
3740
traceback.print_exc()
3841
if isinstance(e, AppApiException):

apps/models_provider/impl/siliconCloud_model_provider/credential/image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from common import forms
1010
from common.exception.app_exception import AppApiException
1111
from common.forms import BaseForm, TooltipLabel
12+
from common.utils.logger import maxkb_logger
1213
from models_provider.base_model_provider import BaseModelCredential, ValidCode
1314
from django.utils.translation import gettext_lazy as _, gettext
1415

@@ -33,6 +34,8 @@ def is_valid(self, model_type: str, model_name, model_credential: Dict[str, obje
3334
try:
3435
model = provider.get_model(model_type, model_name, model_credential, **model_params)
3536
res = model.stream([HumanMessage(content=[{"type": "text", "text": gettext('Hello')}])])
37+
for chunk in res:
38+
maxkb_logger.info(chunk)
3639
except Exception as e:
3740
traceback.print_exc()
3841
if isinstance(e, AppApiException):

apps/models_provider/impl/tencent_model_provider/credential/image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from common import forms
1616
from common.exception.app_exception import AppApiException
1717
from common.forms import BaseForm, TooltipLabel
18+
from common.utils.logger import maxkb_logger
1819
from models_provider.base_model_provider import BaseModelCredential, ValidCode
1920

2021

@@ -35,6 +36,8 @@ def is_valid(self, model_type: str, model_name, model_credential: Dict[str, obje
3536
try:
3637
model = provider.get_model(model_type, model_name, model_credential, **model_params)
3738
res = model.stream([HumanMessage(content=[{"type": "text", "text": gettext('Hello')}])])
39+
for chunk in res:
40+
maxkb_logger.info(chunk)
3841
except Exception as e:
3942
traceback.print_exc()
4043
if isinstance(e, AppApiException):

apps/models_provider/impl/vllm_model_provider/credential/image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from common import forms
99
from common.exception.app_exception import AppApiException
1010
from common.forms import BaseForm, TooltipLabel
11+
from common.utils.logger import maxkb_logger
1112
from models_provider.base_model_provider import BaseModelCredential, ValidCode
1213

1314
class VllmImageModelCredential(BaseForm, BaseModelCredential):
@@ -30,6 +31,8 @@ def is_valid(self, model_type: str, model_name, model_credential: Dict[str, obje
3031
try:
3132
model = provider.get_model(model_type, model_name, model_credential, **model_params)
3233
res = model.stream([HumanMessage(content=[{"type": "text", "text": "你好"}])])
34+
for chunk in res:
35+
maxkb_logger.info(chunk)
3336
except Exception as e:
3437
traceback.print_exc()
3538
if isinstance(e, AppApiException):

apps/models_provider/impl/volcanic_engine_model_provider/credential/image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from common import forms
99
from common.exception.app_exception import AppApiException
1010
from common.forms import BaseForm, TooltipLabel
11+
from common.utils.logger import maxkb_logger
1112
from models_provider.base_model_provider import BaseModelCredential, ValidCode
1213

1314
class VolcanicEngineImageModelCredential(BaseForm, BaseModelCredential):
@@ -30,6 +31,8 @@ def is_valid(self, model_type: str, model_name, model_credential: Dict[str, obje
3031
try:
3132
model = provider.get_model(model_type, model_name, model_credential, **model_params)
3233
res = model.stream([HumanMessage(content=[{"type": "text", "text": gettext('Hello')}])])
34+
for chunk in res:
35+
maxkb_logger.info(chunk)
3336
except Exception as e:
3437
traceback.print_exc()
3538
if isinstance(e, AppApiException):

apps/models_provider/impl/xinference_model_provider/credential/image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from common import forms
88
from common.exception.app_exception import AppApiException
99
from common.forms import BaseForm, TooltipLabel
10+
from common.utils.logger import maxkb_logger
1011
from models_provider.base_model_provider import BaseModelCredential, ValidCode
1112

1213

@@ -30,6 +31,8 @@ def is_valid(self, model_type: str, model_name, model_credential: Dict[str, obje
3031
try:
3132
model = provider.get_model(model_type, model_name, model_credential, **model_params)
3233
res = model.stream([HumanMessage(content=[{"type": "text", "text": gettext('Hello')}])])
34+
for chunk in res:
35+
maxkb_logger.info(chunk)
3336
except Exception as e:
3437
if isinstance(e, AppApiException):
3538
raise e

0 commit comments

Comments
 (0)