Spaces:
Sleeping
Sleeping
Updated app with pre-built assets
Browse files- app.py +4 -4
- assets/embeddings.npy +1 -1
- assets/faiss.index +1 -1
app.py
CHANGED
@@ -44,19 +44,19 @@ def _ensure_index():
|
|
44 |
global _DATA_DF, _INDEX, _EMBEDDINGS
|
45 |
if _INDEX is not None:
|
46 |
return
|
47 |
-
|
48 |
# Load assets from the assets directory
|
49 |
try:
|
50 |
data_path = os.path.join(ASSETS_DIR, "data.parquet")
|
51 |
index_path = os.path.join(ASSETS_DIR, "faiss.index")
|
52 |
emb_path = os.path.join(ASSETS_DIR, "embeddings.npy")
|
53 |
-
|
54 |
_DATA_DF = pd.read_parquet(data_path)
|
55 |
_INDEX = faiss.read_index(index_path)
|
56 |
_EMBEDDINGS = np.load(emb_path)
|
57 |
-
|
58 |
print(f"[INFO] Loaded pre-built FAISS index. rows={len(_DATA_DF)}, dim={_INDEX.d}")
|
59 |
-
|
60 |
except FileNotFoundError:
|
61 |
print("[ERROR] Pre-built assets not found. The space may fail to run.")
|
62 |
print("[INFO] Falling back to building a tiny demo index.")
|
|
|
44 |
global _DATA_DF, _INDEX, _EMBEDDINGS
|
45 |
if _INDEX is not None:
|
46 |
return
|
47 |
+
|
48 |
# Load assets from the assets directory
|
49 |
try:
|
50 |
data_path = os.path.join(ASSETS_DIR, "data.parquet")
|
51 |
index_path = os.path.join(ASSETS_DIR, "faiss.index")
|
52 |
emb_path = os.path.join(ASSETS_DIR, "embeddings.npy")
|
53 |
+
|
54 |
_DATA_DF = pd.read_parquet(data_path)
|
55 |
_INDEX = faiss.read_index(index_path)
|
56 |
_EMBEDDINGS = np.load(emb_path)
|
57 |
+
|
58 |
print(f"[INFO] Loaded pre-built FAISS index. rows={len(_DATA_DF)}, dim={_INDEX.d}")
|
59 |
+
|
60 |
except FileNotFoundError:
|
61 |
print("[ERROR] Pre-built assets not found. The space may fail to run.")
|
62 |
print("[INFO] Falling back to building a tiny demo index.")
|
assets/embeddings.npy
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 106346624
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f270fcc12b35298154a94062b2091d35155662bbcfbe403b433091f4b7d852c4
|
3 |
size 106346624
|
assets/faiss.index
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 106346541
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:121c2308e2791711093c52a14190edad5472a47a1a657530667a8ddc1915f2e3
|
3 |
size 106346541
|