mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-23 08:56:42 +08:00
fix: restore download button when file type is selected in agent message (#17184)
This commit is contained in:
@@ -981,6 +981,9 @@ class Canvas(Graph):
|
||||
message_end["status"] = cpn_obj.get_param("status")
|
||||
if isinstance(cpn_obj.output("attachment"), dict):
|
||||
message_end["attachment"] = cpn_obj.output("attachment")
|
||||
downloads = cpn_obj.output("downloads")
|
||||
if isinstance(downloads, list) and downloads:
|
||||
message_end["downloads"] = downloads
|
||||
if self._has_reference():
|
||||
message_end["reference"] = self.get_reference()
|
||||
# NOTE: aggregated run token usage is intentionally NOT attached here.
|
||||
|
||||
@@ -315,32 +315,6 @@ function MessageItem({
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{/* {isAssistant && item.attachment && item.attachment.doc_id && (
|
||||
<div className="w-full flex items-center justify-end">
|
||||
<Button
|
||||
variant="link"
|
||||
className="p-1 m-0 h-auto text-text-sub-title-invert"
|
||||
onClick={async () => {
|
||||
if (item.attachment?.doc_id) {
|
||||
try {
|
||||
const response = await downloadFile({
|
||||
docId: item.attachment.doc_id,
|
||||
ext: item.attachment.format,
|
||||
});
|
||||
const blob = new Blob([response.data], {
|
||||
type: response.data.type,
|
||||
});
|
||||
downloadFileFromBlob(blob, item.attachment.file_name);
|
||||
} catch (error) {
|
||||
console.error('Download failed:', error);
|
||||
}
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Download size={16} />
|
||||
</Button>
|
||||
</div>
|
||||
)} */}
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import message from '@/components/ui/message';
|
||||
import { Authorization } from '@/constants/authorization';
|
||||
import { ResponseType } from '@/interfaces/database/base';
|
||||
import { IReferenceObject } from '@/interfaces/database/chat';
|
||||
import {
|
||||
IDocumentDownloadInfo,
|
||||
IReferenceObject,
|
||||
} from '@/interfaces/database/chat';
|
||||
import { BeginQuery } from '@/pages/agent/interface';
|
||||
import { getAuthorization } from '@/utils/authorization-util';
|
||||
import { EventSourceParserStream } from 'eventsource-parser/stream';
|
||||
@@ -59,7 +62,9 @@ export interface IMessageData {
|
||||
}
|
||||
|
||||
export interface IMessageEndData {
|
||||
reference: IReferenceObject;
|
||||
reference?: IReferenceObject;
|
||||
attachment?: IAttachment;
|
||||
downloads?: IDocumentDownloadInfo[];
|
||||
}
|
||||
|
||||
export interface ILogData extends INodeData {
|
||||
|
||||
@@ -83,12 +83,21 @@ export function findMessageFromList(eventList: IEventList) {
|
||||
const workflowFinished = eventList.find(
|
||||
(x) => x.event === MessageEventType.WorkflowFinished,
|
||||
) as IMessageEvent;
|
||||
const messageEndEvent = [...eventList]
|
||||
.reverse()
|
||||
.find((x) => x.event === MessageEventType.MessageEnd) as IMessageEndEvent;
|
||||
return {
|
||||
id: eventList[0]?.message_id,
|
||||
content: nextContent,
|
||||
audio_binary: audioBinary,
|
||||
attachment: workflowFinished?.data?.outputs?.attachment || {},
|
||||
downloads: workflowFinished?.data?.outputs?.downloads || [],
|
||||
attachment:
|
||||
workflowFinished?.data?.outputs?.attachment ||
|
||||
messageEndEvent?.data?.attachment ||
|
||||
{},
|
||||
downloads:
|
||||
workflowFinished?.data?.outputs?.downloads ||
|
||||
messageEndEvent?.data?.downloads ||
|
||||
[],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user