Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: with file conversation second chat raise error (#15097)

非法操作d84fa4d15498
diff --git a/web/app/components/base/chat/chat/utils.ts b/web/app/components/base/chat/chat/utils.ts
index 34d00afe33e..69bc6807771 100644
--- a/web/app/components/base/chat/chat/utils.ts
+++ b/web/app/components/base/chat/chat/utils.ts
@@ -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[]) => {
const processedInputs = { ...inputs }
inputsForm.forEach((item) => {
- if (item.type === InputVarType.multiFiles && inputs[item.variable])
- processedInputs[item.variable] = getProcessedFiles(inputs[item.variable])
+ const inputValue = inputs[item.variable]
+ if (!inputValue)
+ return
- if (item.type === InputVarType.singleFile && inputs[item.variable])
- processedInputs[item.variable] = getProcessedFiles([inputs[item.variable]])[0]
+ if (item.type === InputVarType.singleFile) {
+ 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