Spaces:
Sleeping
Sleeping
Davide Panza
commited on
Update app/main_IO.py
Browse files- app/main_IO.py +12 -3
app/main_IO.py
CHANGED
|
@@ -73,12 +73,21 @@ def get_model_path(EMBEDDING_MODEL):
|
|
| 73 |
# Try current working directory
|
| 74 |
cwd_model_path = os.path.join(os.getcwd(), "chromadb_model")
|
| 75 |
|
| 76 |
-
#
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
| 78 |
if os.path.exists(path):
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
# If no local model found, return None to download
|
|
|
|
| 82 |
return None
|
| 83 |
|
| 84 |
|
|
|
|
| 73 |
# Try current working directory
|
| 74 |
cwd_model_path = os.path.join(os.getcwd(), "chromadb_model")
|
| 75 |
|
| 76 |
+
# Additional: Try with sentence-transformers format
|
| 77 |
+
st_model_path = os.path.join(root_path, "models", f"sentence-transformers--{EMBEDDING_MODEL}")
|
| 78 |
+
|
| 79 |
+
# Check which path exists AND contains model files
|
| 80 |
+
for path in [local_model_path, app_model_path, cwd_model_path, st_model_path]:
|
| 81 |
if os.path.exists(path):
|
| 82 |
+
# Optional: Check if it actually contains model files
|
| 83 |
+
if any(f.endswith(('.bin', '.safetensors', '.json')) for f in os.listdir(path)):
|
| 84 |
+
print(f"Found local model at: {path}")
|
| 85 |
+
return path
|
| 86 |
+
else:
|
| 87 |
+
print(f"Path exists but no model files found: {path}")
|
| 88 |
|
| 89 |
# If no local model found, return None to download
|
| 90 |
+
print("No local model found, will download from Hugging Face")
|
| 91 |
return None
|
| 92 |
|
| 93 |
|