Update download_assets.py
Browse files- download_assets.py +10 -9
download_assets.py
CHANGED
@@ -12,7 +12,7 @@ def download_assets():
|
|
12 |
# allow either env var name
|
13 |
token = os.getenv("HUGGINGFACE_HUB_TOKEN") or os.getenv("HUGGINGFACE_API_TOKEN")
|
14 |
|
15 |
-
# list of PDF filenames
|
16 |
pdf_files = [
|
17 |
"71763-gale-encyclopedia-of-medicine.-vol.-1.-2nd-ed.pdf",
|
18 |
"Depression-NIM-2024.pdf",
|
@@ -28,28 +28,29 @@ def download_assets():
|
|
28 |
path = hf_hub_download(
|
29 |
repo_id=repo_id,
|
30 |
repo_type=repo_type,
|
31 |
-
filename=fname,
|
32 |
-
local_dir="data",
|
33 |
token=token,
|
34 |
)
|
35 |
print(f"✅ Downloaded {fname} → {path}")
|
36 |
except Exception as e:
|
37 |
print(f"⚠️ Failed to download {fname}: {e}")
|
38 |
|
39 |
-
# FAISS index files
|
40 |
index_files = ["index.faiss", "index.pkl"]
|
41 |
for fname in index_files:
|
|
|
42 |
try:
|
43 |
path = hf_hub_download(
|
44 |
repo_id=repo_id,
|
45 |
repo_type=repo_type,
|
46 |
-
filename=
|
47 |
-
local_dir="
|
48 |
token=token,
|
49 |
)
|
50 |
-
print(f"✅ Downloaded {
|
51 |
except Exception as e:
|
52 |
-
print(f"⚠️ Failed to download {
|
53 |
|
54 |
if __name__ == "__main__":
|
55 |
-
download_assets()
|
|
|
12 |
# allow either env var name
|
13 |
token = os.getenv("HUGGINGFACE_HUB_TOKEN") or os.getenv("HUGGINGFACE_API_TOKEN")
|
14 |
|
15 |
+
# list of PDF filenames at the repo root
|
16 |
pdf_files = [
|
17 |
"71763-gale-encyclopedia-of-medicine.-vol.-1.-2nd-ed.pdf",
|
18 |
"Depression-NIM-2024.pdf",
|
|
|
28 |
path = hf_hub_download(
|
29 |
repo_id=repo_id,
|
30 |
repo_type=repo_type,
|
31 |
+
filename=fname,
|
32 |
+
local_dir="data",
|
33 |
token=token,
|
34 |
)
|
35 |
print(f"✅ Downloaded {fname} → {path}")
|
36 |
except Exception as e:
|
37 |
print(f"⚠️ Failed to download {fname}: {e}")
|
38 |
|
39 |
+
# Now fetch the FAISS index files from the nested path
|
40 |
index_files = ["index.faiss", "index.pkl"]
|
41 |
for fname in index_files:
|
42 |
+
remote_path = f"vectorstore/db_faiss/{fname}"
|
43 |
try:
|
44 |
path = hf_hub_download(
|
45 |
repo_id=repo_id,
|
46 |
repo_type=repo_type,
|
47 |
+
filename=remote_path, # this is where they actually live in the repo
|
48 |
+
local_dir=".", # so that ./vectorstore/db_faiss/... is created
|
49 |
token=token,
|
50 |
)
|
51 |
+
print(f"✅ Downloaded {remote_path} → {path}")
|
52 |
except Exception as e:
|
53 |
+
print(f"⚠️ Failed to download {remote_path}: {e}")
|
54 |
|
55 |
if __name__ == "__main__":
|
56 |
+
download_assets()
|