MoizK commited on
Commit
67898d2
·
verified ·
1 Parent(s): a25ed9b

Update download_assets.py

Browse files
Files changed (1) hide show
  1. 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 *at the repo root*
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, # no "data/" prefix
32
- local_dir="data", # drop into ./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 also at the repo root
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=fname, # root filename
47
- local_dir="vectorstore/db_faiss", # into ./vectorstore/db_faiss/
48
  token=token,
49
  )
50
- print(f"✅ Downloaded {fname} → {path}")
51
  except Exception as e:
52
- print(f"⚠️ Failed to download {fname}: {e}")
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()