DreamStream-1 commited on
Commit
2534af5
·
verified ·
1 Parent(s): ae9f70f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -24
app.py CHANGED
@@ -1939,22 +1939,23 @@ async def process_incoming_message(from_number: str, msg: dict):
1939
 
1940
  if products:
1941
  logger.info(f"[Process] Product name detected: '{message_body}' -> Found {len(products)} products")
1942
- # If single product found, show it directly
1943
- if len(products) == 1:
1944
- selected_product = products[0]
1945
- product_name = selected_product.get('Product Name', 'Unknown')
1946
- logger.info(f"[Process] Single product found: {product_name}")
1947
- context_manager.update_context(
1948
- from_number,
1949
- current_product=selected_product,
1950
- current_state='product_inquiry',
1951
- current_menu='product_inquiry',
1952
- current_menu_options=list(MENU_CONFIG['product_inquiry']['option_descriptions'].values())
1953
- )
1954
- # Always send image+caption if possible, else text
1955
- logger.info(f"[DEBUG] Calling send_product_image_with_caption for: {product_name}")
1956
- await send_product_image_with_caption(from_number, selected_product, user_context)
1957
- return
 
1958
 
1959
  else:
1960
  # Enhanced "not found" response with veterinary suggestions
@@ -3253,18 +3254,18 @@ def is_valid_menu_selection(selection: str, current_state: str, user_context: di
3253
  def generate_veterinary_welcome_message(phone_number=None, user_context=None):
3254
  """Generate veterinary welcome message"""
3255
  return (
3256
- "🏥 *Welcome to Apex Biotical Veterinary Assistant*\n\n"
3257
  "How can I help you today?\n\n"
3258
- "📋 *Main Menu:*\n"
3259
- "1️⃣ Search Veterinary Products\n"
3260
  "2️⃣ Browse Categories\n"
3261
  "3️⃣ Download Catalog\n"
3262
  "4️⃣ Chat with Veterinary AI Assistant\n\n"
3263
- "💬 *Quick Actions:*\n"
3264
- " Type a product name (e.g., 'hydropex', 'respira aid plus')\n"
3265
- " Ask about symptoms (e.g., 'respiratory problems', 'liver support')\n"
3266
- " Search by category (e.g., 'antibiotics', 'vitamins')\n\n"
3267
- "🎤 *Voice messages are supported!*\n"
3268
  "You can speak product names, menu numbers, or ask questions."
3269
  )
3270
 
 
1939
 
1940
  if products:
1941
  logger.info(f"[Process] Product name detected: '{message_body}' -> Found {len(products)} products")
1942
+ # Show ONLY the highest probability match (first product after sorting by score)
1943
+ selected_product = products[0] # Get the highest scored product
1944
+ product_name = selected_product.get('Product Name', 'Unknown')
1945
+ product_score = selected_product.get('_score', 0)
1946
+ logger.info(f"[Process] Highest probability product: {product_name} (score: {product_score})")
1947
+
1948
+ context_manager.update_context(
1949
+ from_number,
1950
+ current_product=selected_product,
1951
+ current_state='product_inquiry',
1952
+ current_menu='product_inquiry',
1953
+ current_menu_options=list(MENU_CONFIG['product_inquiry']['option_descriptions'].values())
1954
+ )
1955
+ # Always send image+caption if possible, else text
1956
+ logger.info(f"[DEBUG] Calling send_product_image_with_caption for: {product_name}")
1957
+ await send_product_image_with_caption(from_number, selected_product, user_context)
1958
+ return
1959
 
1960
  else:
1961
  # Enhanced "not found" response with veterinary suggestions
 
3254
  def generate_veterinary_welcome_message(phone_number=None, user_context=None):
3255
  """Generate veterinary welcome message"""
3256
  return (
3257
+ "🏥 Welcome to Apex Biotical Solutions Veterinary Virtual Assistant\n\n"
3258
  "How can I help you today?\n\n"
3259
+ "📋 Main Menu:\n"
3260
+ "1️⃣ Complete Products List\n"
3261
  "2️⃣ Browse Categories\n"
3262
  "3️⃣ Download Catalog\n"
3263
  "4️⃣ Chat with Veterinary AI Assistant\n\n"
3264
+ "💬 Quick Actions:\n"
3265
+ "* Type a product name (e.g., 'hydropex', 'respira aid plus')\n"
3266
+ "* Ask about symptoms (e.g., 'respiratory problems', 'liver support')\n"
3267
+ "* Search by category (e.g., 'antibiotics', 'vitamins')\n\n"
3268
+ "🎤 Voice messages are supported!\n"
3269
  "You can speak product names, menu numbers, or ask questions."
3270
  )
3271