From 2c2551e15c25373a54f43f95d6b746989aa44480 Mon Sep 17 00:00:00 2001 From: Timebomb2018 <18868801967@163.com> Date: Fri, 24 Apr 2026 14:44:27 +0800 Subject: [PATCH] feat(citation): add download_url to citations when allow_download is enabled --- api/app/services/workflow_service.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/api/app/services/workflow_service.py b/api/app/services/workflow_service.py index b8f5174c..63b7073e 100644 --- a/api/app/services/workflow_service.py +++ b/api/app/services/workflow_service.py @@ -773,9 +773,16 @@ class WorkflowService: # 过滤 citations citations = result.get("citations", []) citation_cfg = feature_configs.get("citation", {}) - filtered_citations = ( - citations if isinstance(citation_cfg, dict) and citation_cfg.get("enabled") else [] - ) + if isinstance(citation_cfg, dict) and citation_cfg.get("enabled"): + allow_download = citation_cfg.get("allow_download", False) + if allow_download: + from app.core.config import settings + for c in citations: + if c.get("document_id"): + c["download_url"] = f"{settings.FILE_LOCAL_SERVER_URL}/apps/citations/{c['document_id']}/download" + filtered_citations = citations + else: + filtered_citations = [] assistant_meta = {"usage": token_usage, "audio_url": None} if filtered_citations: assistant_meta["citations"] = filtered_citations @@ -975,9 +982,16 @@ class WorkflowService: # 过滤 citations citations = event.get("data", {}).get("citations", []) citation_cfg = feature_configs.get("citation", {}) - filtered_citations = ( - citations if isinstance(citation_cfg, dict) and citation_cfg.get("enabled") else [] - ) + if isinstance(citation_cfg, dict) and citation_cfg.get("enabled"): + allow_download = citation_cfg.get("allow_download", False) + if allow_download: + from app.core.config import settings + for c in citations: + if c.get("document_id"): + c["download_url"] = f"{settings.FILE_LOCAL_SERVER_URL}/apps/citations/{c['document_id']}/download" + filtered_citations = citations + else: + filtered_citations = [] assistant_meta = {"usage": token_usage, "audio_url": None} if filtered_citations: assistant_meta["citations"] = filtered_citations