Skip to content

Commit 880496e

Browse files
committed
feat: 高级编排支持文件上传(WIP)
1 parent 88b6eeb commit 880496e

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

apps/application/flow/step_node/document_extract_node/impl/base_document_extract_node.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
# coding=utf-8
2+
from django.db.models import QuerySet
3+
24
from application.flow.i_step_node import NodeResult
35
from application.flow.step_node.document_extract_node.i_document_extract_node import IDocumentExtractNode
6+
from dataset.models import File
47

58

69
class BaseDocumentExtractNode(IDocumentExtractNode):
710
def execute(self, document, **kwargs):
811
self.context['document_list'] = document
912
content = ''
13+
spliter = '\n-----------------------------------\n'
1014
if len(document) > 0:
1115
for doc in document:
12-
content += doc['name']
13-
content += '\n-----------------------------------\n'
16+
file = QuerySet(File).filter(id=doc['file_id']).first()
17+
file_type = doc['name'].split('.')[-1]
18+
if file_type.lower() in ['txt', 'md', 'csv', 'html']:
19+
content += spliter + doc['name'] + '\n' + file.get_byte().tobytes().decode('utf-8')
20+
21+
1422
return NodeResult({'content': content}, {})
1523

1624
def get_details(self, index: int, **kwargs):

ui/src/components/ai-chat/component/chat-input-operate/index.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const localLoading = computed({
131131
132132
133133
const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp']
134-
const documentExtensions = ['pdf', 'docx', 'txt', 'xls', 'xlsx', 'md', 'html']
134+
const documentExtensions = ['pdf', 'docx', 'txt', 'xls', 'xlsx', 'md', 'html', 'csv']
135135
const videoExtensions = ['mp4', 'avi', 'mov', 'mkv', 'flv']
136136
const audioExtensions = ['mp3', 'wav', 'aac', 'flac']
137137
@@ -185,6 +185,13 @@ const uploadFile = async (file: any, fileList: any) => {
185185
file.file_id = f[0].file_id
186186
}
187187
})
188+
uploadDocumentList.value.forEach((file: any) => {
189+
const f = response.data.filter((f: any) => f.name === file.name)
190+
if (f.length > 0) {
191+
file.url = f[0].url
192+
file.file_id = f[0].file_id
193+
}
194+
})
188195
console.log(uploadDocumentList.value, uploadImageList.value)
189196
})
190197
}

0 commit comments

Comments
 (0)