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

Enhance classification handling in intent extraction and property search

Browse files

- Updated the return structure of `extract_and_update_intent` and `extract_and_search_properties` to include the classification information, improving the context provided for subsequent processing.
- Added debug print statements in `receive_message` to log the classification being processed, enhancing traceability during image request handling.
- These changes aim to improve the clarity and responsiveness of the AI chat system by ensuring that classification data is consistently available and logged throughout the interaction flow.

Files changed (2) hide show
  1. ai_chat.py +12 -3
  2. main.py +4 -0
ai_chat.py CHANGED
@@ -295,7 +295,10 @@ async def extract_and_update_intent(state):
295
  if skip_preferences:
296
  # User is asking for properties, images, or address - don't interrupt with preference questions
297
  print(f"DEBUG - User asking for {classification}, skipping preference questions")
298
- return {"response": None}
 
 
 
299
 
300
  # User is setting preferences, ask for missing fields
301
  questions = {
@@ -309,7 +312,10 @@ async def extract_and_update_intent(state):
309
  return state
310
 
311
  print("DEBUG - Intent update returning None")
312
- return {"response": None}
 
 
 
313
 
314
  async def classify_user_intent(state):
315
  """
@@ -389,7 +395,10 @@ async def extract_and_search_properties(state):
389
 
390
  if properties:
391
  print("DEBUG - Properties found, returning properties to continue to chat")
392
- return {"properties": properties}
 
 
 
393
 
394
  # No properties found with any filters
395
  state["response"] = (
 
295
  if skip_preferences:
296
  # User is asking for properties, images, or address - don't interrupt with preference questions
297
  print(f"DEBUG - User asking for {classification}, skipping preference questions")
298
+ return {
299
+ "response": None,
300
+ "classification": classification
301
+ }
302
 
303
  # User is setting preferences, ask for missing fields
304
  questions = {
 
312
  return state
313
 
314
  print("DEBUG - Intent update returning None")
315
+ return {
316
+ "response": None,
317
+ "classification": state.get("classification")
318
+ }
319
 
320
  async def classify_user_intent(state):
321
  """
 
395
 
396
  if properties:
397
  print("DEBUG - Properties found, returning properties to continue to chat")
398
+ return {
399
+ "properties": properties,
400
+ "classification": state.get("classification")
401
+ }
402
 
403
  # No properties found with any filters
404
  state["response"] = (
main.py CHANGED
@@ -74,9 +74,13 @@ async def receive_message(req: Request):
74
 
75
  # Check if this is an image request
76
  classification = ai_result.get("classification", "")
 
77
  image_messages = None
78
 
79
  if classification.startswith("request_images") or "image" in user_message.lower() or "photo" in user_message.lower():
 
 
 
80
  image_messages = await handle_image_request(state)
81
 
82
  if image_messages:
 
74
 
75
  # Check if this is an image request
76
  classification = ai_result.get("classification", "")
77
+ print(f"DEBUG - main.py classification: '{classification}'")
78
  image_messages = None
79
 
80
  if classification.startswith("request_images") or "image" in user_message.lower() or "photo" in user_message.lower():
81
+ print(f"DEBUG - Calling handle_image_request with classification: '{classification}'")
82
+ # Ensure classification is passed to handle_image_request
83
+ state["classification"] = classification
84
  image_messages = await handle_image_request(state)
85
 
86
  if image_messages: