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: cannot regenerate with image(#15060) (#16611)

Jimmyyaead48726e8b
diff --git a/api/fields/conversation_fields.py b/api/fields/conversation_fields.py
index 80d1f0baf5f..78e0794833e 100644
--- a/api/fields/conversation_fields.py
+++ b/api/fields/conversation_fields.py
@@ -42,6 +42,7 @@ message_file_fields = {
"size": fields.Integer,
"transfer_method": fields.String,
"belongs_to": fields.String(default="user"),
+ "upload_file_id": fields.String(default=None),
}
agent_thought_fields = {
diff --git a/api/models/model.py b/api/models/model.py
index dfc1322d926..a826d13e7d6 100644
--- a/api/models/model.py
+++ b/api/models/model.py
@@ -1155,7 +1155,7 @@ class Message(db.Model): # type: ignore[name-defined]
files.append(file)
result = [
- {"belongs_to": message_file.belongs_to, **file.to_dict()}
+ {"belongs_to": message_file.belongs_to, "upload_file_id": message_file.upload_file_id, **file.to_dict()}
for (file, message_file) in zip(files, message_files)
]
diff --git a/web/app/components/base/chat/chat-with-history/hooks.tsx b/web/app/components/base/chat/chat-with-history/hooks.tsx
index 0a4cbae964f..9afaca2568b 100644
--- a/web/app/components/base/chat/chat-with-history/hooks.tsx
+++ b/web/app/components/base/chat/chat-with-history/hooks.tsx
@@ -52,7 +52,7 @@ function getFormattedChatList(messages: any[]) {
id: `question-${item.id}`,
content: item.query,
isAnswer: false,
- message_files: getProcessedFilesFromResponse(questionFiles.map((item: any) => ({ ...item, related_id: item.id }))),
+ message_files: getProcessedFilesFromResponse(questionFiles.map((item: any) => ({ ...item, related_id: item.id, upload_file_id: item.upload_file_id }))),
parentMessageId: item.parent_message_id || undefined,
})
const answerFiles = item.message_files?.filter((file: any) => file.belongs_to === 'assistant') || []
@@ -63,7 +63,7 @@ function getFormattedChatList(messages: any[]) {
feedback: item.feedback,
isAnswer: true,
citation: item.retriever_resources,
- message_files: getProcessedFilesFromResponse(answerFiles.map((item: any) => ({ ...item, related_id: item.id }))),
+ message_files: getProcessedFilesFromResponse(answerFiles.map((item: any) => ({ ...item, related_id: item.id, upload_file_id: item.upload_file_id }))),
parentMessageId: `question-${item.id}`,
})
})
diff --git a/web/app/components/base/file-uploader/utils.ts b/web/app/components/base/file-uploader/utils.ts
index e095d4aa930..e05c0b20873 100644
--- a/web/app/components/base/file-uploader/utils.ts
+++ b/web/app/components/base/file-uploader/utils.ts
@@ -134,7 +134,7 @@ export const getProcessedFilesFromResponse = (files: FileResponse[]) => {
progress: 100,
transferMethod: fileItem.transfer_method,
supportFileType: fileItem.type,
- uploadedId: fileItem.related_id,
+ uploadedId: fileItem.upload_file_id || fileItem.related_id,
url: fileItem.url,
}
})
diff --git a/web/types/workflow.ts b/web/types/workflow.ts
index 43af64e5cab..bd7334a2613 100644
--- a/web/types/workflow.ts
+++ b/web/types/workflow.ts
@@ -197,6 +197,7 @@ export type FileResponse = {
transfer_method: TransferMethod
type: string
url: string
+ upload_file_id: string
}
export type NodeFinishedResponse = {