From d3482db74de0be7f00bdeb320dc5003e3f3633fe Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 15 Apr 2025 18:41:13 +0800 Subject: [PATCH] chore: can set the write input --- app/components/index.tsx | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/app/components/index.tsx b/app/components/index.tsx index 4d7b28e..df40f9a 100644 --- a/app/components/index.tsx +++ b/app/components/index.tsx @@ -325,13 +325,37 @@ const Main: FC = () => { setChatList(newListWithAnswer) } + const transformToServerFile = (fileItem: any) => { + return { + type: 'image', + transfer_method: fileItem.transferMethod, + url: fileItem.url, + upload_file_id: fileItem.id, + } + } + const handleSend = async (message: string, files?: VisionFile[]) => { if (isResponding) { notify({ type: 'info', message: t('app.errorMessage.waitForResponse') }) return } + const toServerInputs: Record = {} + if (currInputs) { + Object.keys(currInputs).forEach((key) => { + const value = currInputs[key] + if (value.supportFileType) + toServerInputs[key] = transformToServerFile(value) + + else if (value[0]?.supportFileType) + toServerInputs[key] = value.map((item: any) => transformToServerFile(item)) + + else + toServerInputs[key] = value + }) + } + const data: Record = { - inputs: currInputs, + inputs: toServerInputs, query: message, conversation_id: isNewConversation ? null : currConversationId, }