fix upload file size contract (#3408)

This commit is contained in:
Nan Gao
2026-06-06 09:12:17 +02:00
committed by GitHub
parent dd8f9bf5f0
commit 1aac408dd0
6 changed files with 75 additions and 20 deletions
+1 -1
View File
@@ -1209,7 +1209,7 @@ class DeerFlowClient:
info: dict[str, Any] = {
"filename": dest_name,
"size": str(dest.stat().st_size),
"size": dest.stat().st_size,
"path": str(dest),
"virtual_path": upload_virtual_path(dest_name),
"artifact_url": upload_artifact_url(thread_id, dest_name),
@@ -226,8 +226,7 @@ def list_files_in_dir(directory: Path) -> dict:
Returns:
Dict with "files" list (sorted by name) and "count".
Each file entry has ``size`` as *int* (bytes). Call
:func:`enrich_file_listing` to stringify sizes and add
virtual / artifact URLs.
:func:`enrich_file_listing` to add virtual / artifact URLs.
"""
if not directory.is_dir():
return {"files": [], "count": 0}
@@ -298,13 +297,12 @@ def upload_virtual_path(filename: str) -> str:
def enrich_file_listing(result: dict, thread_id: str) -> dict:
"""Add virtual paths, artifact URLs, and stringify sizes on a listing result.
"""Add virtual paths and artifact URLs on a listing result.
Mutates *result* in place and returns it for convenience.
"""
for f in result["files"]:
filename = f["filename"]
f["size"] = str(f["size"])
f["virtual_path"] = upload_virtual_path(filename)
f["artifact_url"] = upload_artifact_url(thread_id, filename)
return result