diff --git a/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py b/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py index 59f8a5fbb12..1fcbc7166a4 100644 --- a/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py +++ b/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py @@ -383,7 +383,7 @@ def get_history_message(history_chat_record, dialogue_number, dialogue_type, run range(start_index if start_index > 0 else 0, len(history_chat_record))], []) for message in history_message: if isinstance(message.content, str): - message.content = re.sub('[\d\D]*?<\/form_rander>', '', message.content) + message.content = re.sub(r'[\d\D]*?', '', message.content) return history_message def generate_prompt_question(self, prompt): diff --git a/apps/application/flow/step_node/application_node/impl/base_application_node.py b/apps/application/flow/step_node/application_node/impl/base_application_node.py index 330bae66441..45995f8303a 100644 --- a/apps/application/flow/step_node/application_node/impl/base_application_node.py +++ b/apps/application/flow/step_node/application_node/impl/base_application_node.py @@ -131,14 +131,14 @@ def reset_application_node_dict(application_node_dict, runtime_node_id, node_dat application_node = application_node_dict[key] if application_node.get('runtime_node_id') == runtime_node_id: content: str = application_node.get('content') - match = re.search('.*?', content) + match = re.search(r'[\d\D]*?', content) if match: form_setting_str = match.group().replace('', '').replace('', '') form_setting = json.loads(form_setting_str) form_setting['is_submit'] = True form_setting['form_data'] = node_data value = f'{json.dumps(form_setting)}' - res = re.sub('.*?', + res = re.sub(r'[\d\D]*?', '${value}', content) application_node['content'] = res.replace('${value}', value) except Exception as e: diff --git a/apps/application/flow/step_node/intent_node/impl/base_intent_node.py b/apps/application/flow/step_node/intent_node/impl/base_intent_node.py index 64822aa9a20..0ac7f375e4b 100644 --- a/apps/application/flow/step_node/intent_node/impl/base_intent_node.py +++ b/apps/application/flow/step_node/intent_node/impl/base_intent_node.py @@ -133,7 +133,7 @@ def get_history_message(history_chat_record, dialogue_number): for message in history_message: if isinstance(message.content, str): - message.content = re.sub('[\d\D]*?<\/form_rander>', '', message.content) + message.content = re.sub(r'[\d\D]*?', '', message.content) return history_message def build_system_prompt(self) -> str: diff --git a/apps/application/flow/step_node/question_node/impl/base_question_node.py b/apps/application/flow/step_node/question_node/impl/base_question_node.py index 3f622c5f2dc..47188e6b848 100644 --- a/apps/application/flow/step_node/question_node/impl/base_question_node.py +++ b/apps/application/flow/step_node/question_node/impl/base_question_node.py @@ -130,7 +130,7 @@ def get_history_message(history_chat_record, dialogue_number): range(start_index if start_index > 0 else 0, len(history_chat_record))], []) for message in history_message: if isinstance(message.content, str): - message.content = re.sub('[\d\D]*?<\/form_rander>', '', message.content) + message.content = re.sub(r'[\d\D]*?', '', message.content) return history_message def generate_prompt_question(self, prompt): diff --git a/apps/common/utils/common.py b/apps/common/utils/common.py index f234ebeaf8c..e587f3aee6c 100644 --- a/apps/common/utils/common.py +++ b/apps/common/utils/common.py @@ -126,7 +126,7 @@ def markdown_to_plain_text(md: str) -> str: # 去除多余的空白字符(包括换行符、制表符等) text = re.sub(r'\s+', ' ', text) # 去除表单渲染 - re.sub(r'[\s\S]*?<\/form_rander>', '', text) + text = re.sub(r'[\d\D]*?', '', text) # 去除首尾空格 text = text.strip() return text diff --git a/apps/knowledge/serializers/common.py b/apps/knowledge/serializers/common.py index e33fa545251..398a63edc63 100644 --- a/apps/knowledge/serializers/common.py +++ b/apps/knowledge/serializers/common.py @@ -186,14 +186,14 @@ def write_image(zip_path: str, image_list: List[str]): if search: text = search.group() if text.startswith('(./oss/file/'): - r = text.replace('(./oss/file/', '').replace(')', '') - r = r.strip().split(" ")[0] - if not is_valid_uuid(r): - break - file = QuerySet(File).filter(id=r).first() + image_id = text.replace('(./oss/file/', '').replace(')', '') + image_id = image_id.strip().split(" ")[0] + if not is_valid_uuid(image_id): + continue + file = QuerySet(File).filter(id=image_id).first() if file is None: - break - zip_inner_path = os.path.join('oss', 'file', r) + continue + zip_inner_path = os.path.join('oss', 'file', image_id) file_path = os.path.join(zip_path, zip_inner_path) if not os.path.exists(os.path.dirname(file_path)): os.makedirs(os.path.dirname(file_path)) diff --git a/apps/knowledge/task/handler.py b/apps/knowledge/task/handler.py index f0a8a54853c..d6e8ce85e30 100644 --- a/apps/knowledge/task/handler.py +++ b/apps/knowledge/task/handler.py @@ -102,7 +102,7 @@ def save_problem(knowledge_id, document_id, paragraph_id, problem): # print(f"paragraph_id: {paragraph_id}") # print(f"problem: {problem}") problem = re.sub(r"^\d+\.\s*", "", problem) - pattern = r"(.*?)" + pattern = r"([\d\D]*?)" match = re.search(pattern, problem) problem = match.group(1) if match else None if problem is None or len(problem) == 0: diff --git a/apps/models_provider/serializers/model_serializer.py b/apps/models_provider/serializers/model_serializer.py index be41df50462..d28727d2d69 100644 --- a/apps/models_provider/serializers/model_serializer.py +++ b/apps/models_provider/serializers/model_serializer.py @@ -150,8 +150,8 @@ def one_meta(self, with_valid=False): super().is_valid(raise_exception=True) model = QuerySet(Model).filter(id=self.data.get("id"), workspace_id=self.data.get('workspace_id', 'None')).first() - if model is None: - raise AppApiException(500, _('Model does not exist')) + if model is None: + raise AppApiException(500, _('Model does not exist')) return {'id': str(model.id), 'provider': model.provider, 'name': model.name, 'model_type': model.model_type, 'model_name': model.model_name, 'status': model.status, diff --git a/apps/trigger/handler/simple_tools.py b/apps/trigger/handler/simple_tools.py index dd3ff5748c8..b8886fc0b33 100644 --- a/apps/trigger/handler/simple_tools.py +++ b/apps/trigger/handler/simple_tools.py @@ -53,5 +53,6 @@ def undeploy(trigger, **kwargs): @return: """ for simple_trigger_handler in simple_trigger_handlers: - return simple_trigger_handler.undeploy(trigger, **kwargs) + if simple_trigger_handler.support(trigger, **kwargs): + return simple_trigger_handler.undeploy(trigger, **kwargs) raise Exception("不支持的触发器类型") diff --git a/ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue b/ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue index bddd993d2d3..3adc99b580c 100644 --- a/ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue +++ b/ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue @@ -274,7 +274,7 @@ function markdownToPlainText(md: string) { } function removeFormRander(text: string) { - return text.replace(/[\s\S]*?<\/form_rander>/g, '').trim() + return text.replace(/[\d\D]*?<\/form_rander>/g, '').trim() } function getKey(keys: Array, index: number) { // 从后往前查找第一个小于等于index的键 diff --git a/ui/src/components/ai-chat/component/operation-button/LogOperationButton.vue b/ui/src/components/ai-chat/component/operation-button/LogOperationButton.vue index 6688e96e62e..12b10e19cd7 100644 --- a/ui/src/components/ai-chat/component/operation-button/LogOperationButton.vue +++ b/ui/src/components/ai-chat/component/operation-button/LogOperationButton.vue @@ -180,7 +180,7 @@ function markdownToPlainText(md: string) { } function removeFormRander(text: string) { - return text.replace(/[\s\S]*?<\/form_rander>/g, '').trim() + return text.replace(/[\d\D]*?<\/form_rander>/g, '').trim() } const playAnswerText = (text: string) => {