Skip to content

Commit 8c08366

Browse files
refactor: remove print.
1 parent 18b40f3 commit 8c08366

File tree

81 files changed

+145
-222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+145
-222
lines changed

apps/application/flow/step_node/text_to_video_step_node/impl/base_text_to_video_node.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def execute(self, model_id, prompt, negative_prompt, dialogue_number, dialogue_t
3737
self.context['dialogue_type'] = dialogue_type
3838
self.context['negative_prompt'] = self.generate_prompt_question(negative_prompt)
3939
video_urls = ttv_model.generate_video(question, negative_prompt)
40-
print('video_urls', video_urls)
4140
# 保存图片
4241
if video_urls is None:
4342
return NodeResult({'answer': gettext('Failed to generate video')}, {})

apps/application/flow/workflow_manage.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import concurrent
1010
import json
1111
import threading
12-
import traceback
1312
from concurrent.futures import ThreadPoolExecutor
1413
from functools import reduce
1514
from typing import List, Dict
@@ -26,6 +25,7 @@
2625
from application.flow.step_node import get_node
2726
from common.handle.base_to_response import BaseToResponse
2827
from common.handle.impl.response.system_to_response import SystemToResponse
28+
from common.utils.logger import maxkb_logger
2929

3030
executor = ThreadPoolExecutor(max_workers=200)
3131

@@ -383,7 +383,7 @@ def run_chain(self, current_node, node_result_future=None):
383383
current_node, node_result_future)
384384
return result
385385
except Exception as e:
386-
traceback.print_exc()
386+
maxkb_logger.error(f'Exception: {e}', exc_info=True)
387387
return None
388388

389389
def hand_node_result(self, current_node, node_result_future):
@@ -395,7 +395,7 @@ def hand_node_result(self, current_node, node_result_future):
395395
list(result)
396396
return current_result
397397
except Exception as e:
398-
traceback.print_exc()
398+
maxkb_logger.error(f'Exception: {e}', exc_info=True)
399399
self.status = 500
400400
current_node.get_write_error_context(e)
401401
self.answer += str(e)
@@ -473,7 +473,7 @@ def hand_event_node_result(self, current_node, node_result_future):
473473
return current_result
474474
except Exception as e:
475475
# 添加节点
476-
traceback.print_exc()
476+
maxkb_logger.error(f'Exception: {e}', exc_info=True)
477477
chunk = self.base_to_response.to_stream_chunk_response(self.params['chat_id'],
478478
self.params['chat_record_id'],
479479
current_node.id,

apps/common/auth/authenticate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
@date:2023/9/4 11:16
77
@desc: 认证类
88
"""
9-
import traceback
109
from importlib import import_module
1110

1211
from django.conf import settings
@@ -18,6 +17,7 @@
1817

1918
from common.exception.app_exception import AppAuthenticationFailed, AppEmbedIdentityFailed, AppChatNumOutOfBoundsFailed, \
2019
AppApiException
20+
from common.utils.logger import maxkb_logger
2121

2222
token_cache = cache.caches['default']
2323

@@ -88,7 +88,7 @@ def authenticate(self, request):
8888
return handle.handle(request, token, token_details.get_token_details)
8989
raise AppAuthenticationFailed(1002, _('Authentication information is incorrect! illegal user'))
9090
except Exception as e:
91-
traceback.print_stack()
91+
maxkb_logger.error(f'Exception: {e}', exc_info=True)
9292
if isinstance(e, AppEmbedIdentityFailed) or isinstance(e, AppChatNumOutOfBoundsFailed) or isinstance(e,
9393
AppApiException):
9494
raise e

apps/common/handle/impl/text/html_split_handle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,5 @@ def get_content(self, file, save_image):
7777
content = buffer.decode(encoding)
7878
return html2text(content)
7979
except BaseException as e:
80-
traceback.print_exception(e)
80+
maxkb_logger.error(f'Exception: {e}', exc_info=True)
8181
return f'{e}'

apps/knowledge/task/sync.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
@desc:
88
"""
99

10-
import logging
1110
import traceback
1211
from typing import List
1312

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# coding=utf-8
2-
import traceback
32
from typing import Dict, Any
43

54
from common import forms
65
from common.exception.app_exception import AppApiException
76
from common.forms import BaseForm
87
from models_provider.base_model_provider import BaseModelCredential, ValidCode
98
from django.utils.translation import gettext as _
10-
9+
from common.utils.logger import maxkb_logger
1110

1211
class AliyunBaiLianAsrSTTModelCredential(BaseForm, BaseModelCredential):
1312
api_url = forms.TextInputField(_('API URL'), required=True)
@@ -41,7 +40,7 @@ def is_valid(self,
4140
try:
4241
model = provider.get_model(model_type, model_name, model_credential)
4342
except Exception as e:
44-
traceback.print_exc()
43+
maxkb_logger.error(f'Exception: {e}', exc_info=True)
4544
if isinstance(e, AppApiException):
4645
raise e
4746
if raise_exception:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
@date:2024/10/16 17:01
77
@desc:
88
"""
9-
import traceback
109
from typing import Dict, Any
1110

1211
from django.utils.translation import gettext as _
@@ -16,6 +15,7 @@
1615
from common.forms import BaseForm, TooltipLabel
1716
from models_provider.base_model_provider import BaseModelCredential, ValidCode
1817
from models_provider.impl.aliyun_bai_lian_model_provider.model.embedding import AliyunBaiLianEmbedding
18+
from common.utils.logger import maxkb_logger
1919

2020
class BaiLianEmbeddingModelParams(BaseForm):
2121
dimensions = forms.SingleSelect(
@@ -69,7 +69,7 @@ def is_valid(
6969
model: AliyunBaiLianEmbedding = provider.get_model(model_type, model_name, model_credential)
7070
model.embed_query(_("Hello"))
7171
except Exception as e:
72-
traceback.print_exc()
72+
maxkb_logger.error(f'Exception: {e}', exc_info=True)
7373
if isinstance(e, AppApiException):
7474
raise e
7575
if raise_exception:

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
@date:2024/7/11 18:41
77
@desc:
88
"""
9-
import traceback
109
from typing import Dict
1110

1211
from django.utils.translation import gettext_lazy as _, gettext
13-
from langchain_core.messages import HumanMessage
1412

1513
from common import forms
1614
from common.exception.app_exception import AppApiException
@@ -69,7 +67,7 @@ def is_valid(
6967
model = provider.get_model(model_type, model_name, model_credential, **model_params)
7068
model.check_auth(model_credential.get('api_key'))
7169
except Exception as e:
72-
traceback.print_exc()
70+
maxkb_logger.error(f'Exception: {e}', exc_info=True)
7371
if isinstance(e, AppApiException):
7472
raise e
7573
if raise_exception:

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# coding=utf-8
22

3-
import traceback
43
from typing import Dict, Any
54

65
from django.utils.translation import gettext_lazy as _, gettext
@@ -9,7 +8,7 @@
98
from common.forms import BaseForm, PasswordInputField, SingleSelect, SliderField, TooltipLabel
109
from common.forms.switch_field import SwitchField
1110
from models_provider.base_model_provider import BaseModelCredential, ValidCode
12-
11+
from common.utils.logger import maxkb_logger
1312

1413
class QwenModelParams(BaseForm):
1514
"""
@@ -85,7 +84,7 @@ def is_valid(
8584
model = provider.get_model(model_type, model_name, model_credential, **model_params)
8685
res = model.check_auth()
8786
except Exception as e:
88-
traceback.print_exc()
87+
maxkb_logger.error(f'Exception: {e}', exc_info=True)
8988
if isinstance(e, AppApiException):
9089
raise e
9190
if raise_exception:

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# coding=utf-8
2-
import traceback
32
from typing import Dict
43

54
from langchain_core.messages import HumanMessage
@@ -9,7 +8,7 @@
98
from common.exception.app_exception import AppApiException
109
from common.forms import BaseForm, TooltipLabel
1110
from models_provider.base_model_provider import BaseModelCredential, ValidCode
12-
11+
from common.utils.logger import maxkb_logger
1312

1413
class BaiLianLLMModelParams(BaseForm):
1514
temperature = forms.SliderField(
@@ -76,7 +75,7 @@ def is_valid(
7675
else:
7776
model.invoke([HumanMessage(content=gettext('Hello'))])
7877
except Exception as e:
79-
traceback.print_exc()
78+
maxkb_logger.error(f'Exception: {e}', exc_info=True)
8079
if isinstance(e, AppApiException):
8180
raise e
8281
if raise_exception:

0 commit comments

Comments
 (0)