Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -116,8 +116,8 @@ def create_faiss_index(_text_chunks, _embedding_model):
|
|
116 |
if embeddings.ndim == 1:
|
117 |
embeddings = embeddings.reshape(1, -1)
|
118 |
if embeddings.shape[0] == 0:
|
119 |
-
|
120 |
-
|
121 |
dimension = embeddings.shape[1]
|
122 |
index = faiss.IndexFlatL2(dimension)
|
123 |
index.add(np.array(embeddings, dtype=np.float32))
|
@@ -161,9 +161,10 @@ def get_product_info(query, products_data):
|
|
161 |
query_lower = query.lower()
|
162 |
found_products = []
|
163 |
for product in products_data:
|
164 |
-
|
165 |
-
|
166 |
-
query_lower
|
|
|
167 |
found_products.append(product)
|
168 |
if found_products:
|
169 |
return json.dumps(found_products, indent=2)
|
@@ -229,7 +230,7 @@ def initialize_twilio_client(acc_sid, auth_tkn): # Changed parameter names
|
|
229 |
return None
|
230 |
|
231 |
def get_new_whatsapp_messages(twilio_client, conversation_service_sid_val, bot_start_time_utc, # Renamed
|
232 |
-
|
233 |
"""Fetches new, unanswered WhatsApp messages from Twilio Conversations."""
|
234 |
if not twilio_client:
|
235 |
st.warning("Twilio client not initialized.")
|
|
|
116 |
if embeddings.ndim == 1:
|
117 |
embeddings = embeddings.reshape(1, -1)
|
118 |
if embeddings.shape[0] == 0:
|
119 |
+
st.warning("No embeddings were generated for FAISS index.")
|
120 |
+
return None, []
|
121 |
dimension = embeddings.shape[1]
|
122 |
index = faiss.IndexFlatL2(dimension)
|
123 |
index.add(np.array(embeddings, dtype=np.float32))
|
|
|
161 |
query_lower = query.lower()
|
162 |
found_products = []
|
163 |
for product in products_data:
|
164 |
+
# Changed keys to match Products.json
|
165 |
+
if query_lower in (product.get("Product_Name", "").lower()) or \
|
166 |
+
query_lower in (product.get("Product_Type", "").lower()) or \
|
167 |
+
query_lower == (product.get("Product_ID", "").lower()):
|
168 |
found_products.append(product)
|
169 |
if found_products:
|
170 |
return json.dumps(found_products, indent=2)
|
|
|
230 |
return None
|
231 |
|
232 |
def get_new_whatsapp_messages(twilio_client, conversation_service_sid_val, bot_start_time_utc, # Renamed
|
233 |
+
processed_message_sids, bot_whatsapp_identity_val): # Renamed
|
234 |
"""Fetches new, unanswered WhatsApp messages from Twilio Conversations."""
|
235 |
if not twilio_client:
|
236 |
st.warning("Twilio client not initialized.")
|