Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
)
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
|
|
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 |
-
"🏥
|
3257 |
"How can I help you today?\n\n"
|
3258 |
-
"📋
|
3259 |
-
"1️⃣
|
3260 |
"2️⃣ Browse Categories\n"
|
3261 |
"3️⃣ Download Catalog\n"
|
3262 |
"4️⃣ Chat with Veterinary AI Assistant\n\n"
|
3263 |
-
"💬
|
3264 |
-
"
|
3265 |
-
"
|
3266 |
-
"
|
3267 |
-
"🎤
|
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 |
|