feat: 高级编排支持文件上传(WIP)

This commit is contained in:
CaptainB 2024-11-13 18:23:00 +08:00 committed by 刘瑞斌
parent 88b6eebf35
commit 02e9774c46
2 changed files with 18 additions and 3 deletions

View File

@ -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):

View File

@ -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)
})
}