zenaight commited on
Commit
f692b71
·
1 Parent(s): 3fdf3b6

Refactor intent extraction and flow control for improved user interaction

Browse files

- Updated the `extract_and_update_intent` function to set the response directly in the state when prompting users for location during property searches, enhancing clarity and flow.
- Modified the `should_continue` function to improve readability and debugging by explicitly checking for the presence of a response, ensuring better control over the conversation flow.
- These changes aim to streamline user interactions by ensuring that location preferences are addressed effectively and that the decision-making process in the chat flow is more transparent.

Files changed (1) hide show
  1. ai_chat.py +5 -5
ai_chat.py CHANGED
@@ -300,10 +300,8 @@ async def extract_and_update_intent(state):
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,
@@ -458,7 +456,9 @@ graph.set_entry_point("persona_update")
458
  # Add conditional edges - if a node returns a response, go to END
459
  def should_continue(state):
460
  """Check if we should continue to the next node or end"""
461
- return state.get("response") is None
 
 
462
 
463
  graph.add_edge("persona_update", "classify_intent")
464
  graph.add_edge("classify_intent", "intent_update")
 
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
+ state["response"] = "I'd be happy to help you find properties! Which area or city are you interested in?"
304
+ return state
 
 
305
 
306
  return {
307
  "response": None,
 
456
  # Add conditional edges - if a node returns a response, go to END
457
  def should_continue(state):
458
  """Check if we should continue to the next node or end"""
459
+ has_response = state.get("response") is not None
460
+ print(f"DEBUG - should_continue: response={state.get('response')}, has_response={has_response}, should_continue={not has_response}")
461
+ return not has_response
462
 
463
  graph.add_edge("persona_update", "classify_intent")
464
  graph.add_edge("classify_intent", "intent_update")