chore: can set the write input

This commit is contained in:
Joel
2025-04-15 18:41:13 +08:00
parent beda954867
commit d3482db74d

View File

@ -325,13 +325,37 @@ const Main: FC<IMainProps> = () => {
setChatList(newListWithAnswer) 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[]) => { const handleSend = async (message: string, files?: VisionFile[]) => {
if (isResponding) { if (isResponding) {
notify({ type: 'info', message: t('app.errorMessage.waitForResponse') }) notify({ type: 'info', message: t('app.errorMessage.waitForResponse') })
return return
} }
const toServerInputs: Record<string, any> = {}
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<string, any> = { const data: Record<string, any> = {
inputs: currInputs, inputs: toServerInputs,
query: message, query: message,
conversation_id: isNewConversation ? null : currConversationId, conversation_id: isNewConversation ? null : currConversationId,
} }