Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

Fix download bug in RAG tutorial (#9156)

Toshiki Ogimoto172c33589ae3
diff --git a/dspy/utils/__init__.py b/dspy/utils/__init__.py
index 8f5e9cf5e..5dd889dd9 100644
--- a/dspy/utils/__init__.py
+++ b/dspy/utils/__init__.py
@@ -16,7 +16,7 @@ def download(url):
remote_size = int(requests.head(url, allow_redirects=True).headers.get("Content-Length", 0))
local_size = os.path.getsize(filename) if os.path.exists(filename) else 0
- if local_size != remote_size:
+ if not os.path.exists(filename) or local_size != remote_size:
print(f"Downloading '{filename}'...")
with requests.get(url, stream=True) as r, open(filename, "wb") as f:
for chunk in r.iter_content(chunk_size=8192):