From 9099b788393692586316f90f131282379e1f9986 Mon Sep 17 00:00:00 2001 From: Billy Bao Date: Fri, 14 Nov 2025 17:02:43 +0800 Subject: [PATCH] current --- agent/component/message.py | 10 +++++++--- api/apps/document_app.py | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/agent/component/message.py b/agent/component/message.py index 4d2051e06..b78cdb90c 100644 --- a/agent/component/message.py +++ b/agent/component/message.py @@ -177,6 +177,9 @@ class Message(ComponentBase): def _convert_content(self, content): doc_id = get_uuid() + + if not self._param.output_format.lower() in {"markdown", "html", "pdf", "docx"}: + self._param.output_format = "markdown" try: if self._param.output_format in {"markdown", "html"}: @@ -223,9 +226,10 @@ class Message(ComponentBase): os.remove(tmp_name) settings.STORAGE_IMPL.put(self._canvas._tenant_id, doc_id, binary_content) - - # document id, format, filename - self.set_output("attachment", (doc_id, self._param.output_format, f"{doc_id[:8]}.{self._param.output_format}")) + self.set_output("attachment", { + "doc_id":doc_id, + "format":self._param.output_format, + "file_name":f"{doc_id[:8]}.{self._param.output_format}"}) logging.info(f"Converted content uploaded as {doc_id} (format={self._param.output_format})") diff --git a/api/apps/document_app.py b/api/apps/document_app.py index c10fecdbf..8cea336de 100644 --- a/api/apps/document_app.py +++ b/api/apps/document_app.py @@ -508,6 +508,7 @@ def get(doc_id): ext = ext.group(1) if ext else None if ext: if doc.type == FileType.VISUAL.value: + content_type = CONTENT_TYPE_MAP.get(ext, f"image/{ext}") else: content_type = CONTENT_TYPE_MAP.get(ext, f"application/{ext}") @@ -523,8 +524,8 @@ def download_attachment(attachment_id): try: ext = request.args.get("ext", "markdown") data = settings.STORAGE_IMPL.get(current_user.id, attachment_id) + # data = settings.STORAGE_IMPL.get("eb500d50bb0411f0907561d2782adda5", attachment_id) response = flask.make_response(data) - response.headers.set("Content-Type", CONTENT_TYPE_MAP.get(ext, f"application/{ext}")) return response