Spaces:
Sleeping
Sleeping
Ajaykanth Maddi commited on
Commit ·
90d2855
1
Parent(s): affdfdf
Code Changes - Optimized code to check for HF repo
Browse files- ragbench.py +10 -0
ragbench.py
CHANGED
|
@@ -86,6 +86,7 @@ class RAGSystem:
|
|
| 86 |
self.embedder = None
|
| 87 |
self.hybrid_retriever = None
|
| 88 |
self.generator_client = None
|
|
|
|
| 89 |
|
| 90 |
# Set up API-based generator
|
| 91 |
self._init_generator_api()
|
|
@@ -113,6 +114,11 @@ class RAGSystem:
|
|
| 113 |
)
|
| 114 |
|
| 115 |
def _check_huggingface_repo(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
try:
|
| 117 |
# 1. First verify the repo exists
|
| 118 |
print("Checking Hugging Face repository...")
|
|
@@ -129,8 +135,12 @@ class RAGSystem:
|
|
| 129 |
repo_id=HF_DATASET_REPO_NAME,
|
| 130 |
repo_type=HF_REPO_TYPE,
|
| 131 |
)
|
|
|
|
|
|
|
|
|
|
| 132 |
for index, item in enumerate(repo_files):
|
| 133 |
print(f"Index, {index}, File: {item}")
|
|
|
|
| 134 |
except Exception as e:
|
| 135 |
print(f"Error accessing Hugging Face repo: {e}")
|
| 136 |
return False
|
|
|
|
| 86 |
self.embedder = None
|
| 87 |
self.hybrid_retriever = None
|
| 88 |
self.generator_client = None
|
| 89 |
+
self.huggingface_repo_exists = False
|
| 90 |
|
| 91 |
# Set up API-based generator
|
| 92 |
self._init_generator_api()
|
|
|
|
| 114 |
)
|
| 115 |
|
| 116 |
def _check_huggingface_repo(self):
|
| 117 |
+
|
| 118 |
+
if self.huggingface_repo_exists:
|
| 119 |
+
print(f"Repository {HF_DATASET_REPO_NAME} already exists, skipping check.")
|
| 120 |
+
return True
|
| 121 |
+
|
| 122 |
try:
|
| 123 |
# 1. First verify the repo exists
|
| 124 |
print("Checking Hugging Face repository...")
|
|
|
|
| 135 |
repo_id=HF_DATASET_REPO_NAME,
|
| 136 |
repo_type=HF_REPO_TYPE,
|
| 137 |
)
|
| 138 |
+
|
| 139 |
+
self.huggingface_repo_exists = True
|
| 140 |
+
print(f"Repository {HF_DATASET_REPO_NAME} is accessible. Files:")
|
| 141 |
for index, item in enumerate(repo_files):
|
| 142 |
print(f"Index, {index}, File: {item}")
|
| 143 |
+
|
| 144 |
except Exception as e:
|
| 145 |
print(f"Error accessing Hugging Face repo: {e}")
|
| 146 |
return False
|