zenaight commited on
Commit ·
e2c07e6
1
Parent(s): b92bfbc
Enhance intent classification and debugging in AI chat
Browse files- Added debug print statements in `extract_and_update_intent` to log missing intent fields and the classification check, improving traceability during intent processing.
- Updated the return structure of `extract_and_update_intent` to include the classification result, enhancing the information provided for subsequent processing.
- These changes aim to refine the intent extraction logic and provide better insights into the classification process, ultimately improving user interactions.
- ai_chat.py +3 -1
ai_chat.py
CHANGED
|
@@ -268,9 +268,11 @@ async def extract_and_update_intent(state):
|
|
| 268 |
print(f"DEBUG - Final intent state: {state['intent']}")
|
| 269 |
|
| 270 |
missing = [f for f in intent_fields if state["intent"].get(f) is None]
|
|
|
|
| 271 |
if missing:
|
| 272 |
# Check if user is asking for properties (using AI classification)
|
| 273 |
classification = state.get("classification")
|
|
|
|
| 274 |
if classification == "search_listings":
|
| 275 |
# User is asking for properties, don't interrupt with preference questions
|
| 276 |
print("DEBUG - User asking for properties, skipping preference questions")
|
|
@@ -308,7 +310,7 @@ Message: {user_message}
|
|
| 308 |
classification = resp.content.strip()
|
| 309 |
state["classification"] = classification
|
| 310 |
print(f"DEBUG - Classification result: '{classification}' for message: '{user_message}'")
|
| 311 |
-
return {"response": None}
|
| 312 |
|
| 313 |
async def extract_and_search_properties(state):
|
| 314 |
"""
|
|
|
|
| 268 |
print(f"DEBUG - Final intent state: {state['intent']}")
|
| 269 |
|
| 270 |
missing = [f for f in intent_fields if state["intent"].get(f) is None]
|
| 271 |
+
print(f"DEBUG - Missing intent fields: {missing}")
|
| 272 |
if missing:
|
| 273 |
# Check if user is asking for properties (using AI classification)
|
| 274 |
classification = state.get("classification")
|
| 275 |
+
print(f"DEBUG - Intent update classification check: '{classification}'")
|
| 276 |
if classification == "search_listings":
|
| 277 |
# User is asking for properties, don't interrupt with preference questions
|
| 278 |
print("DEBUG - User asking for properties, skipping preference questions")
|
|
|
|
| 310 |
classification = resp.content.strip()
|
| 311 |
state["classification"] = classification
|
| 312 |
print(f"DEBUG - Classification result: '{classification}' for message: '{user_message}'")
|
| 313 |
+
return {"classification": classification, "response": None}
|
| 314 |
|
| 315 |
async def extract_and_search_properties(state):
|
| 316 |
"""
|