zenaight commited on
Commit
440c7f4
·
1 Parent(s): 11f5f36

Enhance property inquiry handling in intent extraction

Browse files

- Updated the `extract_and_update_intent` and `extract_and_search_properties` functions to prompt users for location when requesting property listings without a specified location, improving the AI's responsiveness and user experience.
- Added debug statements to clarify the flow of intent processing related to property searches, ensuring better traceability.
- These changes aim to streamline user interactions by ensuring that location preferences are addressed before proceeding with property searches.

Files changed (1) hide show
  1. ai_chat.py +16 -3
ai_chat.py CHANGED
@@ -296,6 +296,15 @@ async def extract_and_update_intent(state):
296
  if skip_preferences:
297
  # User is asking for properties, images, or address - don't interrupt with preference questions
298
  print(f"DEBUG - User asking for {classification}, skipping preference questions")
 
 
 
 
 
 
 
 
 
299
  return {
300
  "response": None,
301
  "classification": classification
@@ -342,6 +351,9 @@ Examples:
342
  - "How big is it?" → request_details
343
  - "Show me images" → request_images
344
  - "What do you have in JHB?" → search_listings
 
 
 
345
 
346
  Return only the tag (and identifier if applicable).
347
  Message: {user_message}
@@ -382,9 +394,10 @@ async def extract_and_search_properties(state):
382
  location = intent.get("location_preference")
383
 
384
  if not location:
385
- # Missing location, skip property search
386
- print("DEBUG - No location found, skipping property search")
387
- return {"response": None}
 
388
 
389
  # Prepare filters for property search
390
  filters = {"location_preference": location}
 
296
  if skip_preferences:
297
  # User is asking for properties, images, or address - don't interrupt with preference questions
298
  print(f"DEBUG - User asking for {classification}, skipping preference questions")
299
+
300
+ # Special case: if user is asking for properties but has no location, ask for location first
301
+ if classification == "search_listings" and not state["intent"].get("location_preference"):
302
+ print("DEBUG - User asking for properties but no location, asking for location")
303
+ return {
304
+ "response": "I'd be happy to help you find properties! Which area or city are you interested in?",
305
+ "classification": classification
306
+ }
307
+
308
  return {
309
  "response": None,
310
  "classification": classification
 
351
  - "How big is it?" → request_details
352
  - "Show me images" → request_images
353
  - "What do you have in JHB?" → search_listings
354
+ - "Do you have any properties for sale?" → search_listings
355
+ - "Any properties available?" → search_listings
356
+ - "Show me properties" → search_listings
357
 
358
  Return only the tag (and identifier if applicable).
359
  Message: {user_message}
 
394
  location = intent.get("location_preference")
395
 
396
  if not location:
397
+ # Missing location, but user is asking for properties - ask for location
398
+ print("DEBUG - No location found, asking for location")
399
+ state["response"] = "I'd be happy to help you find properties! Which area or city are you interested in?"
400
+ return state
401
 
402
  # Prepare filters for property search
403
  filters = {"location_preference": location}