Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2086,18 +2086,21 @@ async def process_incoming_message(from_number: str, msg: dict):
|
|
2086 |
logger.info(f"[Process] Checking for product name in message: '{message_body}' from state: {current_state}")
|
2087 |
products = get_veterinary_product_matches(message_body)
|
2088 |
|
2089 |
-
# ---
|
2090 |
normalized_input = normalize(message_body).lower().strip()
|
2091 |
exact_match = None
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
|
|
|
|
|
|
|
|
2099 |
if exact_match:
|
2100 |
-
logger.info(f"[Process] Exact product match found: {exact_match.get('Product Name', 'Unknown')}")
|
2101 |
context_manager.update_context(
|
2102 |
from_number,
|
2103 |
current_product=exact_match,
|
|
|
2086 |
logger.info(f"[Process] Checking for product name in message: '{message_body}' from state: {current_state}")
|
2087 |
products = get_veterinary_product_matches(message_body)
|
2088 |
|
2089 |
+
# --- IMPROVED LOGIC: Check for exact product name match first ---
|
2090 |
normalized_input = normalize(message_body).lower().strip()
|
2091 |
exact_match = None
|
2092 |
+
|
2093 |
+
# First, try to find exact product name match in the database
|
2094 |
+
if products_df is not None and not products_df.empty:
|
2095 |
+
for _, row in products_df.iterrows():
|
2096 |
+
product_name = str(row.get('Product Name', '')).lower().strip()
|
2097 |
+
normalized_product_name = normalize(product_name).lower().strip()
|
2098 |
+
if normalized_product_name == normalized_input:
|
2099 |
+
exact_match = row.to_dict()
|
2100 |
+
logger.info(f"[Process] Exact product name match found: {exact_match.get('Product Name', 'Unknown')}")
|
2101 |
+
break
|
2102 |
+
|
2103 |
if exact_match:
|
|
|
2104 |
context_manager.update_context(
|
2105 |
from_number,
|
2106 |
current_product=exact_match,
|