Spaces:
Sleeping
Sleeping
Update app/main_IO.py
Browse files- app/main_IO.py +0 -31
app/main_IO.py
CHANGED
|
@@ -61,37 +61,6 @@ def reset_session_state_on_upload():
|
|
| 61 |
for key, default_val in DEFAULT_SESSION_STATE.items():
|
| 62 |
if key != 'questions_to_download':
|
| 63 |
st.session_state[key] = default_val
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
def get_model_path(EMBEDDING_MODEL):
|
| 67 |
-
# Define root_path within the function
|
| 68 |
-
root_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
| 69 |
-
|
| 70 |
-
# Try local model first (relative to current script)
|
| 71 |
-
local_model_path = os.path.join(os.path.dirname(__file__), "chromadb_model")
|
| 72 |
-
|
| 73 |
-
# Try app root model folder
|
| 74 |
-
app_model_path = os.path.join(root_path, "models", EMBEDDING_MODEL)
|
| 75 |
-
|
| 76 |
-
# Try current working directory
|
| 77 |
-
cwd_model_path = os.path.join(os.getcwd(), "chromadb_model")
|
| 78 |
-
|
| 79 |
-
# Additional: Try with sentence-transformers format
|
| 80 |
-
st_model_path = os.path.join(root_path, "models", f"sentence-transformers--{EMBEDDING_MODEL}")
|
| 81 |
-
|
| 82 |
-
# Check which path exists AND contains model files
|
| 83 |
-
for path in [local_model_path, app_model_path, cwd_model_path, st_model_path]:
|
| 84 |
-
if os.path.exists(path):
|
| 85 |
-
# Optional: Check if it actually contains model files
|
| 86 |
-
if any(f.endswith(('.bin', '.safetensors', '.json')) for f in os.listdir(path)):
|
| 87 |
-
print(f"Found local model at: {path}")
|
| 88 |
-
return path
|
| 89 |
-
else:
|
| 90 |
-
print(f"Path exists but no model files found: {path}")
|
| 91 |
-
|
| 92 |
-
# If no local model found, return None to download
|
| 93 |
-
print("No local model found, will download from Hugging Face")
|
| 94 |
-
return None
|
| 95 |
|
| 96 |
|
| 97 |
def upload_pdf():
|
|
|
|
| 61 |
for key, default_val in DEFAULT_SESSION_STATE.items():
|
| 62 |
if key != 'questions_to_download':
|
| 63 |
st.session_state[key] = default_val
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
|
| 66 |
def upload_pdf():
|