feat: 高级编排支持文件上传(WIP)
This commit is contained in:
parent
88b6eebf35
commit
02e9774c46
@ -1,16 +1,24 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
from django.db.models import QuerySet
|
||||||
|
|
||||||
from application.flow.i_step_node import NodeResult
|
from application.flow.i_step_node import NodeResult
|
||||||
from application.flow.step_node.document_extract_node.i_document_extract_node import IDocumentExtractNode
|
from application.flow.step_node.document_extract_node.i_document_extract_node import IDocumentExtractNode
|
||||||
|
from dataset.models import File
|
||||||
|
|
||||||
|
|
||||||
class BaseDocumentExtractNode(IDocumentExtractNode):
|
class BaseDocumentExtractNode(IDocumentExtractNode):
|
||||||
def execute(self, document, **kwargs):
|
def execute(self, document, **kwargs):
|
||||||
self.context['document_list'] = document
|
self.context['document_list'] = document
|
||||||
content = ''
|
content = ''
|
||||||
|
spliter = '\n-----------------------------------\n'
|
||||||
if len(document) > 0:
|
if len(document) > 0:
|
||||||
for doc in document:
|
for doc in document:
|
||||||
content += doc['name']
|
file = QuerySet(File).filter(id=doc['file_id']).first()
|
||||||
content += '\n-----------------------------------\n'
|
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}, {})
|
return NodeResult({'content': content}, {})
|
||||||
|
|
||||||
def get_details(self, index: int, **kwargs):
|
def get_details(self, index: int, **kwargs):
|
||||||
|
|||||||
@ -131,7 +131,7 @@ const localLoading = computed({
|
|||||||
|
|
||||||
|
|
||||||
const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp']
|
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 videoExtensions = ['mp4', 'avi', 'mov', 'mkv', 'flv']
|
||||||
const audioExtensions = ['mp3', 'wav', 'aac', 'flac']
|
const audioExtensions = ['mp3', 'wav', 'aac', 'flac']
|
||||||
|
|
||||||
@ -185,6 +185,13 @@ const uploadFile = async (file: any, fileList: any) => {
|
|||||||
file.file_id = f[0].file_id
|
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)
|
console.log(uploadDocumentList.value, uploadImageList.value)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user