Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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('<form_rander>[\d\D]*?<\/form_rander>', '', message.content)
message.content = re.sub(r'<form_rander>[\d\D]*?</form_rander>', '', message.content)
return history_message

def generate_prompt_question(self, prompt):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('<form_rander>.*?</form_rander>', content)
match = re.search(r'<form_rander>[\d\D]*?</form_rander>', content)
if match:
form_setting_str = match.group().replace('<form_rander>', '').replace('</form_rander>', '')
form_setting = json.loads(form_setting_str)
form_setting['is_submit'] = True
form_setting['form_data'] = node_data
value = f'<form_rander>{json.dumps(form_setting)}</form_rander>'
res = re.sub('<form_rander>.*?</form_rander>',
res = re.sub(r'<form_rander>[\d\D]*?</form_rander>',
'${value}', content)
application_node['content'] = res.replace('${value}', value)
except Exception as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('<form_rander>[\d\D]*?<\/form_rander>', '', message.content)
message.content = re.sub(r'<form_rander>[\d\D]*?</form_rander>', '', message.content)
return history_message

def build_system_prompt(self) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('<form_rander>[\d\D]*?<\/form_rander>', '', message.content)
message.content = re.sub(r'<form_rander>[\d\D]*?</form_rander>', '', message.content)
return history_message

def generate_prompt_question(self, prompt):
Expand Down
2 changes: 1 addition & 1 deletion apps/common/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def markdown_to_plain_text(md: str) -> str:
# 去除多余的空白字符(包括换行符、制表符等)
text = re.sub(r'\s+', ' ', text)
# 去除表单渲染
re.sub(r'<form_rander>[\s\S]*?<\/form_rander>', '', text)
text = re.sub(r'<form_rander>[\d\D]*?</form_rander>', '', text)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

遗漏了 text = ,导致实际上并未去除表单渲染

# 去除首尾空格
text = text.strip()
return text
Expand Down
2 changes: 1 addition & 1 deletion apps/knowledge/task/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"<question>(.*?)</question>"
pattern = r"<question>([\d\D]*?)</question>"
match = re.search(pattern, problem)
problem = match.group(1) if match else None
if problem is None or len(problem) == 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ function markdownToPlainText(md: string) {
}

function removeFormRander(text: string) {
return text.replace(/<form_rander>[\s\S]*?<\/form_rander>/g, '').trim()
return text.replace(/<form_rander>[\d\D]*?<\/form_rander>/g, '').trim()
}
function getKey(keys: Array<number>, index: number) {
// 从后往前查找第一个小于等于index的键
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function markdownToPlainText(md: string) {
}

function removeFormRander(text: string) {
return text.replace(/<form_rander>[\s\S]*?<\/form_rander>/g, '').trim()
return text.replace(/<form_rander>[\d\D]*?<\/form_rander>/g, '').trim()
}

const playAnswerText = (text: string) => {
Expand Down
Loading