Upload folder using huggingface_hub
Browse files- advanced_rag.py +3 -6
advanced_rag.py
CHANGED
|
@@ -2174,14 +2174,11 @@ https://www.gutenberg.org/ebooks/8438.txt.utf-8
|
|
| 2174 |
|
| 2175 |
def create_csv_from_batch_results(results: List[Dict], job_id: str) -> str:
|
| 2176 |
"""Create a CSV file from batch query results and return the file path"""
|
| 2177 |
-
#
|
| 2178 |
-
csv_dir = os.path.join(tempfile.gettempdir(), "rag_batch_results")
|
| 2179 |
-
os.makedirs(csv_dir, exist_ok=True)
|
| 2180 |
-
|
| 2181 |
# Create a unique filename using job_id and timestamp
|
| 2182 |
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 2183 |
csv_filename = f"batch_results_{job_id}_{timestamp}.csv"
|
| 2184 |
-
csv_path = os.path.
|
| 2185 |
|
| 2186 |
# Extract parameters and responses
|
| 2187 |
data = []
|
|
@@ -2256,4 +2253,4 @@ def format_batch_result_files(results: List[Dict], job_id: str) -> Tuple[str, st
|
|
| 2256 |
|
| 2257 |
if __name__ == "__main__":
|
| 2258 |
debug_print("Launching Gradio interface.")
|
| 2259 |
-
app.queue().launch(share=False, allowed_paths=[os.
|
|
|
|
| 2174 |
|
| 2175 |
def create_csv_from_batch_results(results: List[Dict], job_id: str) -> str:
|
| 2176 |
"""Create a CSV file from batch query results and return the file path"""
|
| 2177 |
+
# Save CSV files in the current directory for HuggingFace Spaces compatibility
|
|
|
|
|
|
|
|
|
|
| 2178 |
# Create a unique filename using job_id and timestamp
|
| 2179 |
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 2180 |
csv_filename = f"batch_results_{job_id}_{timestamp}.csv"
|
| 2181 |
+
csv_path = os.path.abspath(csv_filename)
|
| 2182 |
|
| 2183 |
# Extract parameters and responses
|
| 2184 |
data = []
|
|
|
|
| 2253 |
|
| 2254 |
if __name__ == "__main__":
|
| 2255 |
debug_print("Launching Gradio interface.")
|
| 2256 |
+
app.queue().launch(share=False, allowed_paths=[os.getcwd()])
|