fix: 修复工作流知识库检索结果标题不存在的时候显示错误 #1535
This commit is contained in:
parent
5285745321
commit
6a226c9539
@ -37,6 +37,13 @@ def get_none_result(question):
|
|||||||
'directly_return': ''}, {})
|
'directly_return': ''}, {})
|
||||||
|
|
||||||
|
|
||||||
|
def reset_title(title):
|
||||||
|
if title is None or len(title.strip()) == 0:
|
||||||
|
return ""
|
||||||
|
else:
|
||||||
|
return f"#### {title}\n"
|
||||||
|
|
||||||
|
|
||||||
class BaseSearchDatasetNode(ISearchDatasetStepNode):
|
class BaseSearchDatasetNode(ISearchDatasetStepNode):
|
||||||
def execute(self, dataset_id_list, dataset_setting, question,
|
def execute(self, dataset_id_list, dataset_setting, question,
|
||||||
exclude_paragraph_id_list=None,
|
exclude_paragraph_id_list=None,
|
||||||
@ -63,10 +70,11 @@ class BaseSearchDatasetNode(ISearchDatasetStepNode):
|
|||||||
return NodeResult({'paragraph_list': result,
|
return NodeResult({'paragraph_list': result,
|
||||||
'is_hit_handling_method_list': [row for row in result if row.get('is_hit_handling_method')],
|
'is_hit_handling_method_list': [row for row in result if row.get('is_hit_handling_method')],
|
||||||
'data': '\n'.join(
|
'data': '\n'.join(
|
||||||
[f"{paragraph.get('title', '')}:{paragraph.get('content')}" for paragraph in
|
[f"{reset_title(paragraph.get('title', ''))}{paragraph.get('content')}" for paragraph in
|
||||||
paragraph_list])[0:dataset_setting.get('max_paragraph_char_number', 5000)],
|
paragraph_list])[0:dataset_setting.get('max_paragraph_char_number', 5000)],
|
||||||
'directly_return': '\n'.join(
|
'directly_return': '\n'.join(
|
||||||
[f"{paragraph.get('title', '')}:{paragraph.get('content')}" for paragraph in result if
|
[f"{reset_title(paragraph.get('title', ''))}{paragraph.get('content')}" for paragraph in
|
||||||
|
result if
|
||||||
paragraph.get('is_hit_handling_method')]),
|
paragraph.get('is_hit_handling_method')]),
|
||||||
'question': question},
|
'question': question},
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user