Skip to content

Commit

Permalink
feat: 高级编排支持文件上传(WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuruibin committed Nov 9, 2024
1 parent 4fb2523 commit 28d67a7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ def get_node_params_serializer_class(self) -> Type[serializers.Serializer]:
def _run(self):
res = self.workflow_manage.get_reference_field(self.node_params_serializer.data.get('image_list')[0],
self.node_params_serializer.data.get('image_list')[1:])
self.node_params_serializer.data['image'] = res
return self.execute(**self.node_params_serializer.data, **self.flow_params_serializer.data)
return self.execute(image = res, **self.node_params_serializer.data, **self.flow_params_serializer.data)

def execute(self, model_id, system, prompt, dialogue_number, history_chat_record, stream, chat_id,
chat_record_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def generate_prompt_question(self, prompt):

def generate_message_list(self, image_model, system: str, prompt: str, history_message, image):
if image is not None and len(image) > 0:
file_id = image[0].url.split('/')[-1]
file_id = image[0]['file_id']
file = QuerySet(File).filter(id=file_id).first()

if system is not None and len(system) > 0:
Expand Down
2 changes: 1 addition & 1 deletion apps/application/views/chat_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,6 @@ def post(self, request: Request, application_id: str, chat_id: str):
meta = {'application_id': application_id, 'chat_id': chat_id}
for file in files:
file_url = FileSerializer(data={'file': file, 'meta': meta}).upload()
file_ids.append({'name': file.name, 'url': file_url})
file_ids.append({'name': file.name, 'url': file_url, 'file_id': file_url.split('/')[-1]})
return result.success(file_ids)

1 change: 1 addition & 0 deletions ui/src/components/ai-chat/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ const uploadFile = async (file: any, fileList: 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(uploadFileList.value)
Expand Down

0 comments on commit 28d67a7

Please sign in to comment.