zenaight commited on
Commit
1e1a0a5
·
1 Parent(s): 2d19bd0

Refine direct summary trigger logic in chat_with_session_memory

Browse files

- Updated the conditions for triggering a direct summary response to only activate for general area searches, enhancing the relevance of responses to user queries.
- This change aims to improve user experience by ensuring that specific requests do not inadvertently prompt a summary, thereby providing clearer and more contextually appropriate information.

Files changed (1) hide show
  1. ai_chat.py +8 -4
ai_chat.py CHANGED
@@ -15,10 +15,14 @@ def chat_with_session_memory(state):
15
  msg_lower = state["user_message"].lower()
16
  props = state.get("properties", [])
17
 
18
- #–– If we have search results and the user asked "show" or "what do you have" ––
19
- triggers = ["show", "what do you have", "properties", "listings"]
20
- if props and any(t in msg_lower for t in triggers):
21
- # build a direct summary
 
 
 
 
22
  response_text = ""
23
  status = state.get("search_status_message")
24
  if status:
 
15
  msg_lower = state["user_message"].lower()
16
  props = state.get("properties", [])
17
 
18
+ #–– Only trigger direct summary for general area searches, not specific requests ––
19
+ is_general_area_search = (
20
+ ("what do you have" in msg_lower or "show me" in msg_lower) and
21
+ any(word in msg_lower for word in ["in ", "area", "jhb", "johannesburg", "cape town", "durban"])
22
+ )
23
+
24
+ if props and is_general_area_search:
25
+ # build a direct summary only for general area searches
26
  response_text = ""
27
  status = state.get("search_status_message")
28
  if status: