Skip to content

Commit 6a226c9

Browse files
committed
fix: 修复工作流知识库检索结果标题不存在的时候显示错误 #1535
1 parent 5285745 commit 6a226c9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

apps/application/flow/step_node/search_dataset_node/impl/base_search_dataset_node.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ def get_none_result(question):
3737
'directly_return': ''}, {})
3838

3939

40+
def reset_title(title):
41+
if title is None or len(title.strip()) == 0:
42+
return ""
43+
else:
44+
return f"#### {title}\n"
45+
46+
4047
class BaseSearchDatasetNode(ISearchDatasetStepNode):
4148
def execute(self, dataset_id_list, dataset_setting, question,
4249
exclude_paragraph_id_list=None,
@@ -63,10 +70,11 @@ def execute(self, dataset_id_list, dataset_setting, question,
6370
return NodeResult({'paragraph_list': result,
6471
'is_hit_handling_method_list': [row for row in result if row.get('is_hit_handling_method')],
6572
'data': '\n'.join(
66-
[f"{paragraph.get('title', '')}:{paragraph.get('content')}" for paragraph in
73+
[f"{reset_title(paragraph.get('title', ''))}{paragraph.get('content')}" for paragraph in
6774
paragraph_list])[0:dataset_setting.get('max_paragraph_char_number', 5000)],
6875
'directly_return': '\n'.join(
69-
[f"{paragraph.get('title', '')}:{paragraph.get('content')}" for paragraph in result if
76+
[f"{reset_title(paragraph.get('title', ''))}{paragraph.get('content')}" for paragraph in
77+
result if
7078
paragraph.get('is_hit_handling_method')]),
7179
'question': question},
7280

0 commit comments

Comments
 (0)