Spaces:
Sleeping
Sleeping
Update file_utils.py
Browse files- file_utils.py +10 -1
file_utils.py
CHANGED
@@ -44,4 +44,13 @@ def load_file(file_path: str) -> str:
|
|
44 |
return ""
|
45 |
except Exception as e:
|
46 |
print(f"Error reading file '{file_path}': {e}")
|
47 |
-
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
return ""
|
45 |
except Exception as e:
|
46 |
print(f"Error reading file '{file_path}': {e}")
|
47 |
+
return ""
|
48 |
+
|
49 |
+
def save_embeddings(embeddings: dict, file_path: str) -> None:
|
50 |
+
"""Saves embeddings to a pickle file safely."""
|
51 |
+
try:
|
52 |
+
with open(file_path, "wb") as file:
|
53 |
+
pickle.dump(embeddings, file)
|
54 |
+
except Exception as e:
|
55 |
+
print(f"Error saving embeddings to '{file_path}': {e}")
|
56 |
+
|