Fix critical issue: Disable WhatsApp improved search to use GPT-5 warehouse search
Browse files- WhatsApp improved search was bypassing GPT-5 warehouse search
- Added debug logging to smart_warehouse_with_price.py
- Now MADONE SL 6 queries will go through correct GPT-5 search path
- app.py +8 -6
- smart_warehouse_with_price.py +18 -0
    	
        app.py
    CHANGED
    
    | @@ -23,12 +23,14 @@ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - % | |
| 23 | 
             
            logger = logging.getLogger(__name__)
         | 
| 24 |  | 
| 25 | 
             
            # Import improved WhatsApp search for BF space
         | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
|  | |
|  | |
| 32 |  | 
| 33 | 
             
            # Import GPT-5 powered smart warehouse search - complete BF algorithm
         | 
| 34 | 
             
            try:
         | 
|  | |
| 23 | 
             
            logger = logging.getLogger(__name__)
         | 
| 24 |  | 
| 25 | 
             
            # Import improved WhatsApp search for BF space
         | 
| 26 | 
            +
            # DISABLED - Using GPT-5 smart warehouse search instead
         | 
| 27 | 
            +
            USE_IMPROVED_SEARCH = False
         | 
| 28 | 
            +
            # try:
         | 
| 29 | 
            +
            #     from whatsapp_improved_chatbot import WhatsAppImprovedChatbot
         | 
| 30 | 
            +
            #     USE_IMPROVED_SEARCH = True
         | 
| 31 | 
            +
            # except ImportError:
         | 
| 32 | 
            +
            #     print("Improved WhatsApp chatbot not available, using basic search")
         | 
| 33 | 
            +
            #     USE_IMPROVED_SEARCH = False
         | 
| 34 |  | 
| 35 | 
             
            # Import GPT-5 powered smart warehouse search - complete BF algorithm
         | 
| 36 | 
             
            try:
         | 
    	
        smart_warehouse_with_price.py
    CHANGED
    
    | @@ -169,6 +169,24 @@ def get_warehouse_stock_smart_with_price(user_message, previous_result=None): | |
| 169 | 
             
                if asked_warehouse:
         | 
| 170 | 
             
                    warehouse_filter = f"\nIMPORTANT: User is asking specifically about {asked_warehouse} warehouse. Only return products available in that warehouse."
         | 
| 171 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 172 | 
             
                # GPT-5 prompt with enhanced instructions
         | 
| 173 | 
             
                smart_prompt = f"""User is asking: "{user_message}"
         | 
| 174 |  | 
|  | |
| 169 | 
             
                if asked_warehouse:
         | 
| 170 | 
             
                    warehouse_filter = f"\nIMPORTANT: User is asking specifically about {asked_warehouse} warehouse. Only return products available in that warehouse."
         | 
| 171 |  | 
| 172 | 
            +
                # Debug logging
         | 
| 173 | 
            +
                print(f"DEBUG - Searching for: '{user_message}'")
         | 
| 174 | 
            +
                print(f"DEBUG - Total products to search: {len(products_summary)}")
         | 
| 175 | 
            +
                
         | 
| 176 | 
            +
                # Check if the target product exists
         | 
| 177 | 
            +
                search_term = user_message.upper()
         | 
| 178 | 
            +
                matching_products = []
         | 
| 179 | 
            +
                for p in products_summary:
         | 
| 180 | 
            +
                    if search_term in p['name'].upper():
         | 
| 181 | 
            +
                        matching_products.append(p)
         | 
| 182 | 
            +
                
         | 
| 183 | 
            +
                if matching_products:
         | 
| 184 | 
            +
                    print(f"DEBUG - Found {len(matching_products)} products containing '{user_message}':")
         | 
| 185 | 
            +
                    for p in matching_products[:3]:
         | 
| 186 | 
            +
                        print(f"  - Index {p['index']}: {p['name']} ({p.get('variant', '')})")
         | 
| 187 | 
            +
                else:
         | 
| 188 | 
            +
                    print(f"DEBUG - No products found containing '{user_message}'")
         | 
| 189 | 
            +
                
         | 
| 190 | 
             
                # GPT-5 prompt with enhanced instructions
         | 
| 191 | 
             
                smart_prompt = f"""User is asking: "{user_message}"
         | 
| 192 |  | 
