Skip to content

Commit

Permalink
fix: 修复节点数据为空的时候,到处日志报错的缺陷
Browse files Browse the repository at this point in the history
  • Loading branch information
wxg0103 committed Oct 30, 2024
1 parent 798ca17 commit d49a785
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions apps/application/serializers/chat_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ def list(self, with_valid=True):
@staticmethod
def paragraph_list_to_string(paragraph_list):
return "\n**********\n".join(
[f"{paragraph.get('title')}:\n{paragraph.get('content')}" for paragraph in paragraph_list])
[f"{paragraph.get('title')}:\n{paragraph.get('content')}" for paragraph in
paragraph_list] if paragraph_list is not None else '')

@staticmethod
def to_row(row: Dict):
Expand All @@ -183,13 +184,14 @@ def to_row(row: Dict):
"step_type") == 'search_step']
reference_paragraph_len = '\n'.join([str(len(node.get('paragraph_list',
[]))) if key == 'search_step' else node.get(
'name') + ':' + str(len(node.get('paragraph_list', []))) for
'name') + ':' + str(
len(node.get('paragraph_list', [])) if node.get('paragraph_list', []) is not None else '0') for
key, node in search_dataset_node_list])
reference_paragraph = '\n----------\n'.join(
[ChatSerializers.Query.paragraph_list_to_string(node.get('paragraph_list',
[])) if key == 'search_step' else node.get(
'name') + ':\n' + ChatSerializers.Query.paragraph_list_to_string(node.get('paragraph_list',
[])) for
[])) for
key, node in search_dataset_node_list])
improve_paragraph_list = row.get('improve_paragraph_list')
vote_status_map = {'-1': '未投票', '0': '赞同', '1': '反对'}
Expand Down

0 comments on commit d49a785

Please sign in to comment.