From adb4c9b4946579790a85787a2253752a4bef3674 Mon Sep 17 00:00:00 2001
From: Christophe Bornet <cbornet@hotmail.com>
Date: Tue, 26 Mar 2024 15:53:26 +0100
Subject: [PATCH] Fix download_llama_dataset and download_llama_pack (#12273)

---
 llama-index-core/llama_index/core/download/utils.py       | 6 ++++--
 llama-index-legacy/llama_index/legacy/download/dataset.py | 4 +++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/llama-index-core/llama_index/core/download/utils.py b/llama-index-core/llama_index/core/download/utils.py
index e8dd91c28..1e9af5c07 100644
--- a/llama-index-core/llama_index/core/download/utils.py
+++ b/llama-index-core/llama_index/core/download/utils.py
@@ -90,7 +90,9 @@ def initialize_directory(
 
 def get_source_files_list(source_tree_url: str, path: str) -> List[str]:
     """Get the list of source files to download."""
-    resp = requests.get(source_tree_url + path + "?recursive=1")
+    resp = requests.get(
+        source_tree_url + path + "?recursive=1", headers={"Accept": "application/json"}
+    )
     payload = resp.json()["payload"]
     return [item["name"] for item in payload["tree"]["items"]]
 
@@ -105,7 +107,7 @@ def recursive_tree_traverse(
         url = tree_urls[0]
 
         try:
-            res = requests.get(url)
+            res = requests.get(url, headers={"Accept": "application/json"})
             tree_elements = res.json()["payload"]["tree"]["items"]
         except Exception:
             raise ValueError("Failed to traverse github tree source.")
diff --git a/llama-index-legacy/llama_index/legacy/download/dataset.py b/llama-index-legacy/llama_index/legacy/download/dataset.py
index bb5f22c21..dac3fb10a 100644
--- a/llama-index-legacy/llama_index/legacy/download/dataset.py
+++ b/llama-index-legacy/llama_index/legacy/download/dataset.py
@@ -47,7 +47,9 @@ def _resolve_dataset_file_name(class_name: str) -> str:
 
 def _get_source_files_list(source_tree_url: str, path: str) -> List[str]:
     """Get the list of source files to download."""
-    resp = requests.get(source_tree_url + path + "?recursive=1")
+    resp = requests.get(
+        source_tree_url + path + "?recursive=1", headers={"Accept": "application/json"}
+    )
     payload = resp.json()["payload"]
     return [item["name"] for item in payload["tree"]["items"]]
 
-- 
GitLab