zenaight commited on
Commit
f817f6b
·
1 Parent(s): 9900964

Add debug statements to handle_image_request for improved traceability

Browse files

- Introduced additional debug print statements in the `handle_image_request` function to log the classification, properties count, property identifier, selected property, and images found.
- These changes aim to enhance the debugging process by providing clearer insights into the image request handling flow, ultimately improving the maintainability and clarity of the code.

Files changed (1) hide show
  1. ai_chat.py +11 -0
ai_chat.py CHANGED
@@ -472,8 +472,11 @@ async def handle_image_request(state):
472
  props = state.get("properties", [])
473
  classification = state.get("classification", "")
474
 
 
 
475
  # Check if this is an image request
476
  if not classification.startswith("request_images") or not props:
 
477
  return None
478
 
479
  # Extract property identifier from classification if present
@@ -481,6 +484,9 @@ async def handle_image_request(state):
481
  if ":" in classification:
482
  property_identifier = classification.split(":", 1)[1].lower()
483
 
 
 
 
484
  # Smart property selection based on AI classification
485
  selected_property = None
486
 
@@ -526,9 +532,14 @@ async def handle_image_request(state):
526
  if not selected_property:
527
  selected_property = props[0]
528
 
 
 
529
  # Get images from selected property
530
  images = selected_property.get("images", [])
531
 
 
 
 
532
  if not images:
533
  property_title = selected_property.get("title", "this listing")
534
  return [f"Sorry, I don't have any images available for {property_title}."]
 
472
  props = state.get("properties", [])
473
  classification = state.get("classification", "")
474
 
475
+ print(f"DEBUG - handle_image_request: classification='{classification}', props count={len(props)}")
476
+
477
  # Check if this is an image request
478
  if not classification.startswith("request_images") or not props:
479
+ print(f"DEBUG - Image request check failed: classification starts with request_images? {classification.startswith('request_images')}, has props? {len(props) > 0}")
480
  return None
481
 
482
  # Extract property identifier from classification if present
 
484
  if ":" in classification:
485
  property_identifier = classification.split(":", 1)[1].lower()
486
 
487
+ print(f"DEBUG - Property identifier: '{property_identifier}'")
488
+ print(f"DEBUG - Available properties: {[p.get('title') for p in props]}")
489
+
490
  # Smart property selection based on AI classification
491
  selected_property = None
492
 
 
532
  if not selected_property:
533
  selected_property = props[0]
534
 
535
+ print(f"DEBUG - Selected property: '{selected_property.get('title')}'")
536
+
537
  # Get images from selected property
538
  images = selected_property.get("images", [])
539
 
540
+ print(f"DEBUG - Images found: {len(images) if images else 0}")
541
+ print(f"DEBUG - Image URLs: {images}")
542
+
543
  if not images:
544
  property_title = selected_property.get("title", "this listing")
545
  return [f"Sorry, I don't have any images available for {property_title}."]