diff --git a/apps/application/flow/step_node/document_extract_node/impl/base_document_extract_node.py b/apps/application/flow/step_node/document_extract_node/impl/base_document_extract_node.py index 35fc6edff..176230d2d 100644 --- a/apps/application/flow/step_node/document_extract_node/impl/base_document_extract_node.py +++ b/apps/application/flow/step_node/document_extract_node/impl/base_document_extract_node.py @@ -1,16 +1,24 @@ # coding=utf-8 +from django.db.models import QuerySet + from application.flow.i_step_node import NodeResult from application.flow.step_node.document_extract_node.i_document_extract_node import IDocumentExtractNode +from dataset.models import File class BaseDocumentExtractNode(IDocumentExtractNode): def execute(self, document, **kwargs): self.context['document_list'] = document content = '' + spliter = '\n-----------------------------------\n' if len(document) > 0: for doc in document: - content += doc['name'] - content += '\n-----------------------------------\n' + file = QuerySet(File).filter(id=doc['file_id']).first() + file_type = doc['name'].split('.')[-1] + if file_type.lower() in ['txt', 'md', 'csv', 'html']: + content += spliter + doc['name'] + '\n' + file.get_byte().tobytes().decode('utf-8') + + return NodeResult({'content': content}, {}) def get_details(self, index: int, **kwargs): diff --git a/ui/src/components/ai-chat/component/chat-input-operate/index.vue b/ui/src/components/ai-chat/component/chat-input-operate/index.vue index b3bee751a..520621a91 100644 --- a/ui/src/components/ai-chat/component/chat-input-operate/index.vue +++ b/ui/src/components/ai-chat/component/chat-input-operate/index.vue @@ -131,7 +131,7 @@ const localLoading = computed({ const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp'] -const documentExtensions = ['pdf', 'docx', 'txt', 'xls', 'xlsx', 'md', 'html'] +const documentExtensions = ['pdf', 'docx', 'txt', 'xls', 'xlsx', 'md', 'html', 'csv'] const videoExtensions = ['mp4', 'avi', 'mov', 'mkv', 'flv'] const audioExtensions = ['mp3', 'wav', 'aac', 'flac'] @@ -185,6 +185,13 @@ const uploadFile = async (file: any, fileList: any) => { file.file_id = f[0].file_id } }) + uploadDocumentList.value.forEach((file: any) => { + const f = response.data.filter((f: any) => f.name === file.name) + if (f.length > 0) { + file.url = f[0].url + file.file_id = f[0].file_id + } + }) console.log(uploadDocumentList.value, uploadImageList.value) }) }