zenaight commited on
Commit
d5a9769
·
1 Parent(s): f66e81d

Enhance user clarification handling in message processing

Browse files

- Added logic to address user confusion or clarification requests, providing tailored responses based on the context of previous AI messages.
- Improved interaction flow by offering specific follow-up information about properties when users express uncertainty, enhancing user engagement and support.

Files changed (1) hide show
  1. ai_chat.py +10 -0
ai_chat.py CHANGED
@@ -445,6 +445,16 @@ async def process_message(user_message: str, user_info: dict = None, session_id:
445
  print(f"Property suggestion: {msg}")
446
  return property_msgs[0] if property_msgs else "Let me know if you'd like to see images or more details!"
447
 
 
 
 
 
 
 
 
 
 
 
448
  if is_property_search and not is_greeting:
449
  print(f"Property search detected: {user_message}")
450
  property_msgs = await handle_property_search(user_message, updated_persona)
 
445
  print(f"Property suggestion: {msg}")
446
  return property_msgs[0] if property_msgs else "Let me know if you'd like to see images or more details!"
447
 
448
+ # Handle confusion or clarification requests
449
+ if user_message.lower() in ["?", "huh", "what", "confused", "not sure", "what do you mean"]:
450
+ if session_messages and session_messages[-1]["role"] == "assistant":
451
+ last_ai_message = session_messages[-1]["content"]
452
+ if "Which of these properties catches your eye" in last_ai_message:
453
+ return "I just showed you a property in Edenvale! It's a 304 sqm warehouse with office space, parking, and 24/7 security. Would you like me to tell you more about it, or would you prefer to see other options?"
454
+ elif "property" in last_ai_message.lower():
455
+ return "I'm here to help you find industrial properties! I can search for warehouses, factories, or commercial spaces. What type of property are you looking for?"
456
+ return "I'm here to help you find industrial properties! What can I assist you with today?"
457
+
458
  if is_property_search and not is_greeting:
459
  print(f"Property search detected: {user_message}")
460
  property_msgs = await handle_property_search(user_message, updated_persona)