Spaces:
Build error
Build error
Commit ·
165d157
1
Parent(s): 5fafef7
Update app.py
Browse files
app.py
CHANGED
|
@@ -66,7 +66,6 @@ model = None
|
|
| 66 |
def initialize_model():
|
| 67 |
"""
|
| 68 |
Initialize the sentence transformer model.
|
| 69 |
-
|
| 70 |
Returns:
|
| 71 |
bool: Whether the model was successfully initialized.
|
| 72 |
"""
|
|
@@ -195,6 +194,13 @@ def semantic_search(query, top_k=5):
|
|
| 195 |
# Load saved embeddings and chunks from OUTPUTS_DIR
|
| 196 |
embeddings_file = os.path.join(OUTPUTS_DIR, "embeddings.npy")
|
| 197 |
chunks_file = os.path.join(OUTPUTS_DIR, "chunks.txt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
stored_embeddings = np.load(embeddings_file)
|
| 199 |
with open(chunks_file, "r", encoding="utf-8") as f:
|
| 200 |
chunks = f.read().split("\n===CHUNK_SEPARATOR===\n")
|
|
|
|
| 66 |
def initialize_model():
|
| 67 |
"""
|
| 68 |
Initialize the sentence transformer model.
|
|
|
|
| 69 |
Returns:
|
| 70 |
bool: Whether the model was successfully initialized.
|
| 71 |
"""
|
|
|
|
| 194 |
# Load saved embeddings and chunks from OUTPUTS_DIR
|
| 195 |
embeddings_file = os.path.join(OUTPUTS_DIR, "embeddings.npy")
|
| 196 |
chunks_file = os.path.join(OUTPUTS_DIR, "chunks.txt")
|
| 197 |
+
|
| 198 |
+
logger.info(f"Checking for embeddings file: {embeddings_file}")
|
| 199 |
+
logger.info(f"Checking for chunks file: {chunks_file}")
|
| 200 |
+
|
| 201 |
+
if not os.path.exists(embeddings_file) or not os.path.exists(chunks_file):
|
| 202 |
+
return "Embeddings or chunks not found. Please generate embeddings first."
|
| 203 |
+
|
| 204 |
stored_embeddings = np.load(embeddings_file)
|
| 205 |
with open(chunks_file, "r", encoding="utf-8") as f:
|
| 206 |
chunks = f.read().split("\n===CHUNK_SEPARATOR===\n")
|