原始文件气泡映射错误 + 多版本下载错版本

This commit is contained in:
runny committed 2026-06-02 21:07:04 +08:00
1 parent f877f61efd
commit 854bc8e4db
7 files changed
+203 -80

No files matched your search

+5 -9
View File
@@ -246,10 +246,13 @@ def _fetch_preview_source_bytes(file_url: str, max_size: int | None=15 * 1024 *
log = db.session.query(ChatLog).filter(stmt).params(url=f'%{raw_url}%').order_by(ChatLog.created_at.desc()).first()
if log and log.retriever_resources:
for r in log.retriever_resources:
if not isinstance(r, dict):
continue
source_url = str(r.get('source_download_url') or '')
if source_url == raw_url or (source_url and source_url.split('&token=')[0] == raw_url.split('&token=')[0]):
dataset_id = dataset_id or str(r.get('dataset_id') or r.get('metadata', {}).get('dataset_id') or '').strip()
remote_document_id = remote_document_id or str(r.get('remote_document_id') or r.get('metadata', {}).get('remote_document_id') or r.get('document_id') or '').strip()
resolved_dataset_id, resolved_remote_document_id = DifyService._extract_dify_ids(r)
dataset_id = dataset_id or str(resolved_dataset_id or '').strip()
remote_document_id = remote_document_id or str(resolved_remote_document_id or '').strip()
if dataset_id and remote_document_id:
break
except Exception as e:
@@ -1411,12 +1414,6 @@ def resolve_source_file():
source_ext = str(payload.get('source_ext') or '').strip().lower()
source_download_url = payload.get('source_download_url')
if source_ext in {'txt', 'md', 'markdown', 'csv', 'vtt', 'properties', 'html', 'htm'}:
current_agent = getattr(g, 'current_agent', None)
source_download_url = (
f"{request.host_url.rstrip('/')}/api/chat/source-file-text"
f"?agent_id={getattr(current_agent, 'id', '')}&dataset_id={dataset_id}&remote_document_id={remote_document_id}"
)
return jsonify({
'dataset_id': dataset_id,
@@ -1649,7 +1646,6 @@ def preview_file_raw():
# 避免在服务端走旧版转换链路导致长时间卡住。
needs_pdf_conversion = (
request.args.get('download') != '1'
and original_ext in ('doc', 'ppt', 'pptx')
and ext in ('doc', 'ppt', 'pptx')
)
if needs_pdf_conversion: