Skip to content

Commit d49a785

Browse files
committed
fix: 修复节点数据为空的时候,到处日志报错的缺陷
1 parent 798ca17 commit d49a785

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

apps/application/serializers/chat_serializers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ def list(self, with_valid=True):
170170
@staticmethod
171171
def paragraph_list_to_string(paragraph_list):
172172
return "\n**********\n".join(
173-
[f"{paragraph.get('title')}:\n{paragraph.get('content')}" for paragraph in paragraph_list])
173+
[f"{paragraph.get('title')}:\n{paragraph.get('content')}" for paragraph in
174+
paragraph_list] if paragraph_list is not None else '')
174175

175176
@staticmethod
176177
def to_row(row: Dict):
@@ -183,13 +184,14 @@ def to_row(row: Dict):
183184
"step_type") == 'search_step']
184185
reference_paragraph_len = '\n'.join([str(len(node.get('paragraph_list',
185186
[]))) if key == 'search_step' else node.get(
186-
'name') + ':' + str(len(node.get('paragraph_list', []))) for
187+
'name') + ':' + str(
188+
len(node.get('paragraph_list', [])) if node.get('paragraph_list', []) is not None else '0') for
187189
key, node in search_dataset_node_list])
188190
reference_paragraph = '\n----------\n'.join(
189191
[ChatSerializers.Query.paragraph_list_to_string(node.get('paragraph_list',
190192
[])) if key == 'search_step' else node.get(
191193
'name') + ':\n' + ChatSerializers.Query.paragraph_list_to_string(node.get('paragraph_list',
192-
[])) for
194+
[])) for
193195
key, node in search_dataset_node_list])
194196
improve_paragraph_list = row.get('improve_paragraph_list')
195197
vote_status_map = {'-1': '未投票', '0': '赞同', '1': '反对'}

0 commit comments

Comments
 (0)