Spaces:
Sleeping
Sleeping
Update src/chatbot_engine.py
Browse files27 unmodified lines28293031323327 unmodified linesif os.path.exists(p):vector_store_path = pbreakself.embeddings = HuggingFaceEmbeddings(model_name="nomic-ai/nomic-embed-text-v1.5",model_kwargs={'trust_remote_code': True}27 unmodified lines2829303132333435363738394041424344454647484950515253545556575859606127 unmodified linesif os.path.exists(p):vector_store_path = pbreak# --- FUSE / NETWORK MOUNT FIX ---# SQLite struggles with file locks on HuggingFace Dataset mounts.# We copy the sqlite file to local fast storage and symlink the indices.if vector_store_path.startswith("/data/"):import shutillocal_db_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "db", "vector_store")os.makedirs(local_db_path, exist_ok=True)print(f"Dataset mount detected. Copying SQLite DB to local storage to prevent locking timeout... (This may take a minute)")# Copy the sqlite filesqlite_src = os.path.join(vector_store_path, "chroma.sqlite3")sqlite_dst = os.path.join(local_db_path, "chroma.sqlite3")if os.path.exists(sqlite_src) and not os.path.exists(sqlite_dst):shutil.copy2(sqlite_src, sqlite_dst)# Symlink all other directories (the heavy vector indices)for item in os.listdir(vector_store_path):if item == "chroma.sqlite3":continuesrc_item = os.path.join(vector_store_path, item)dst_item = os.path.join(local_db_path, item)if os.path.isdir(src_item) and not os.path.exists(dst_item):os.symlink(src_item, dst_item)vector_store_path = local_db_pathprint("Database ready!")self.embeddings = HuggingFaceEmbeddings(model_name="nomic-ai/nomic-embed-text-v1.5",model_kwargs={'trust_remote_code': True}
src/chatbot_engine.py+28