mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 15:05:54 +08:00
fix: with file conversation second chat raise error (#15097)
This commit is contained in:
parent
d574706600
commit
d84fa4d154
@ -17,15 +17,35 @@ export const processOpeningStatement = (openingStatement: string, inputs: Record
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const processInputFileFromServer = (fileItem: Record<string, any>) => {
|
||||||
|
return {
|
||||||
|
type: fileItem.type,
|
||||||
|
transfer_method: fileItem.transfer_method,
|
||||||
|
url: fileItem.remote_url,
|
||||||
|
upload_file_id: fileItem.related_id,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const getProcessedInputs = (inputs: Record<string, any>, inputsForm: InputForm[]) => {
|
export const getProcessedInputs = (inputs: Record<string, any>, inputsForm: InputForm[]) => {
|
||||||
const processedInputs = { ...inputs }
|
const processedInputs = { ...inputs }
|
||||||
|
|
||||||
inputsForm.forEach((item) => {
|
inputsForm.forEach((item) => {
|
||||||
if (item.type === InputVarType.multiFiles && inputs[item.variable])
|
const inputValue = inputs[item.variable]
|
||||||
processedInputs[item.variable] = getProcessedFiles(inputs[item.variable])
|
if (!inputValue)
|
||||||
|
return
|
||||||
|
|
||||||
if (item.type === InputVarType.singleFile && inputs[item.variable])
|
if (item.type === InputVarType.singleFile) {
|
||||||
processedInputs[item.variable] = getProcessedFiles([inputs[item.variable]])[0]
|
if ('transfer_method' in inputValue)
|
||||||
|
processedInputs[item.variable] = processInputFileFromServer(inputValue)
|
||||||
|
else
|
||||||
|
processedInputs[item.variable] = getProcessedFiles([inputValue])[0]
|
||||||
|
}
|
||||||
|
else if (item.type === InputVarType.multiFiles) {
|
||||||
|
if ('transfer_method' in inputValue[0])
|
||||||
|
processedInputs[item.variable] = inputValue.map(processInputFileFromServer)
|
||||||
|
else
|
||||||
|
processedInputs[item.variable] = getProcessedFiles(inputValue)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return processedInputs
|
return processedInputs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user