zenaight commited on
Commit
5fa177b
·
1 Parent(s): a822a4f

Refactor property information handling in AI chat responses

Browse files

- Removed redundant property search logic from `process_message`, streamlining the response generation process.
- Simplified key guidelines for the AI's conversational context, focusing on user needs without excessive detail.
- Enhanced clarity in the response structure, ensuring a more natural interaction flow while maintaining user engagement.

Files changed (1) hide show
  1. ai_chat.py +2 -28
ai_chat.py CHANGED
@@ -64,17 +64,11 @@ Context:
64
  {context}
65
 
66
  Key guidelines:
 
67
  - Be helpful and informative about industrial properties
68
  - Keep responses conversational and not robotic
69
- - If user asks for property search, help them find properties
70
  - Always respond naturally and conversationally
71
- - If user asks for specific property information (URL, photos, features, viewing), you can search the database for that information
72
- - Use the conversation context to understand which property they're referring to
73
-
74
- Available actions you can take:
75
- - Search for properties by city, size, features, or price
76
- - Get detailed information about specific properties
77
- - Provide property URLs, photos, features, and viewing arrangements
78
 
79
  Respond naturally to the user's message: {user_message}"""
80
 
@@ -91,26 +85,6 @@ Respond naturally to the user's message: {user_message}"""
91
  response = llm.invoke(messages)
92
  ai_response = response.content.strip()
93
 
94
- # If the AI response indicates it needs property information, search the database
95
- if any(keyword in user_message.lower() for keyword in ["property", "properties", "warehouse", "office", "space", "listing", "url", "photos", "features"]):
96
- # Extract potential search parameters from user message
97
- city = None
98
- if persona.get("location_preference"):
99
- city = persona["location_preference"]
100
-
101
- # Search for properties
102
- properties = await search_properties_for_ai(city=city, limit=5)
103
-
104
- if properties:
105
- # Add property information to the response
106
- property_info = "\n\nAvailable properties:\n"
107
- for i, prop in enumerate(properties[:3], 1):
108
- property_info += f"{i}. {prop['title']} - {prop['location']}, {prop['city']} - {prop['size_sqm']} sqm - R{prop['price']:,.0f}/month\n"
109
- property_info += f" URL: {prop.get('listing_url', 'N/A')}\n"
110
- property_info += f" Features: {', '.join(prop.get('features', [])[:5])}\n\n"
111
-
112
- ai_response += property_info
113
-
114
  return {
115
  "response": ai_response,
116
  "user_message": user_message,
 
64
  {context}
65
 
66
  Key guidelines:
67
+ - You are a property agent with access to real property listings
68
  - Be helpful and informative about industrial properties
69
  - Keep responses conversational and not robotic
 
70
  - Always respond naturally and conversationally
71
+ - Use the conversation context to understand what the user needs
 
 
 
 
 
 
72
 
73
  Respond naturally to the user's message: {user_message}"""
74
 
 
85
  response = llm.invoke(messages)
86
  ai_response = response.content.strip()
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  return {
89
  "response": ai_response,
90
  "user_message": user_message,