Skip to content

Commit 32b3295

Browse files
committed
fix: 修复知识库导出无文档知识库导出无法打开文件
1 parent 6ad9bd8 commit 32b3295

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

apps/dataset/serializers/document_serializers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ def get_workbook(data_dict, document_dict):
500500
# 创建工作簿对象
501501
workbook = openpyxl.Workbook()
502502
workbook.remove_sheet(workbook.active)
503+
if len(data_dict.keys()) == 0:
504+
data_dict['sheet'] = []
503505
for sheet_id in data_dict:
504506
# 添加工作表
505507
worksheet = workbook.create_sheet(document_dict.get(sheet_id))
@@ -982,8 +984,6 @@ def generate_related(self, model_id, prompt, with_valid=True):
982984
except AlreadyQueued as e:
983985
raise AppApiException(500, "任务正在执行中,请勿重复下发")
984986

985-
986-
987987
class BatchGenerateRelated(ApiMixin, serializers.Serializer):
988988
dataset_id = serializers.UUIDField(required=True, error_messages=ErrMessage.uuid("知识库id"))
989989

@@ -995,7 +995,8 @@ def batch_generate_related(self, instance: Dict, with_valid=True):
995995
model_id = instance.get("model_id")
996996
prompt = instance.get("prompt")
997997
for document_id in document_id_list:
998-
DocumentSerializers.GenerateRelated(data={'document_id': document_id}).generate_related(model_id, prompt)
998+
DocumentSerializers.GenerateRelated(data={'document_id': document_id}).generate_related(model_id,
999+
prompt)
9991000

10001001

10011002
class FileBufferHandle:

0 commit comments

Comments
 (0)