feat(citation): support downloading cited documents with allow_download toggle

Added `allow_download` flag to citation config and `download_url` field to citation output. Implemented `/citations/{document_id}/download` endpoint to serve original files when enabled. Removed unused `files` field and `HttpRequestDataProcessing` model from HTTP request node config.
This commit is contained in:
Timebomb2018
2026-04-24 14:18:25 +08:00
parent f4c168d904
commit 89f2f9a045
4 changed files with 58 additions and 17 deletions

View File

@@ -475,11 +475,19 @@ class AgentRunService:
features_config: Dict[str, Any],
citations: List[Citation]
) -> List[Any]:
"""根据 citation 开关决定是否返回引用来源"""
"""根据 citation 开关决定是否返回引用来源,并根据 allow_download 附加下载链接"""
citation_cfg = features_config.get("citation", {})
if isinstance(citation_cfg, dict) and citation_cfg.get("enabled"):
return [cit.model_dump() for cit in citations]
return []
if not (isinstance(citation_cfg, dict) and citation_cfg.get("enabled")):
return []
allow_download = citation_cfg.get("allow_download", False)
result = []
for cit in citations:
item = cit.model_dump() if hasattr(cit, "model_dump") else dict(cit)
if allow_download and item.get("document_id"):
from app.core.config import settings
item["download_url"] = f"{settings.FILE_LOCAL_SERVER_URL}/apps/citations/{item['document_id']}/download"
result.append(item)
return result
async def run(
self,