Spaces:
Running
Running
Update custom_utils.py
Browse files- custom_utils.py +78 -17
custom_utils.py
CHANGED
|
@@ -139,7 +139,7 @@ def vector_search_naive(openai_api_key,
|
|
| 139 |
}
|
| 140 |
}
|
| 141 |
|
| 142 |
-
pipeline = [vector_search_stage,
|
| 143 |
|
| 144 |
return invoke_search(db, collection, pipeline)
|
| 145 |
|
|
@@ -172,7 +172,7 @@ def vector_search_advanced(openai_api_key,
|
|
| 172 |
}
|
| 173 |
}
|
| 174 |
|
| 175 |
-
pipeline = [vector_search_and_filter_stage,
|
| 176 |
|
| 177 |
return invoke_search(db, collection, pipeline)
|
| 178 |
|
|
@@ -184,22 +184,83 @@ def get_remove_fields_stage():
|
|
| 184 |
def get_project_fields_stage():
|
| 185 |
return {
|
| 186 |
"$project": {
|
| 187 |
-
"_id":
|
| 188 |
-
"
|
| 189 |
-
"
|
| 190 |
-
"
|
| 191 |
-
"
|
| 192 |
-
"
|
| 193 |
-
"
|
| 194 |
-
"
|
| 195 |
-
"address.location.type": 1,
|
| 196 |
-
"address.location.coordinates": 1,
|
| 197 |
-
"address.location.is_location_exact": 1,
|
| 198 |
-
"summary": 1,
|
| 199 |
-
"space": 1,
|
| 200 |
"neighborhood_overview": 1,
|
| 201 |
-
"
|
| 202 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
}
|
| 204 |
}
|
| 205 |
|
|
|
|
| 139 |
}
|
| 140 |
}
|
| 141 |
|
| 142 |
+
pipeline = [vector_search_stage, get_project_fields_stage()]
|
| 143 |
|
| 144 |
return invoke_search(db, collection, pipeline)
|
| 145 |
|
|
|
|
| 172 |
}
|
| 173 |
}
|
| 174 |
|
| 175 |
+
pipeline = [vector_search_and_filter_stage, get_project_fields_stage()] + additional_stages
|
| 176 |
|
| 177 |
return invoke_search(db, collection, pipeline)
|
| 178 |
|
|
|
|
| 184 |
def get_project_fields_stage():
|
| 185 |
return {
|
| 186 |
"$project": {
|
| 187 |
+
"_id": 1,
|
| 188 |
+
"id": 1,
|
| 189 |
+
"listing_url": 1,
|
| 190 |
+
"scrape_id": 1,
|
| 191 |
+
"last_scraped": 1,
|
| 192 |
+
"source": 1,
|
| 193 |
+
"name": 1,
|
| 194 |
+
"description": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
"neighborhood_overview": 1,
|
| 196 |
+
"picture_url": 1,
|
| 197 |
+
"host_id": 1,
|
| 198 |
+
"host_url": 1,
|
| 199 |
+
"host_name": 1,
|
| 200 |
+
"host_since": 1,
|
| 201 |
+
"host_location": 1,
|
| 202 |
+
"host_about": 1,
|
| 203 |
+
"host_response_time": 1,
|
| 204 |
+
"host_response_rate": 1,
|
| 205 |
+
"host_acceptance_rate": 1,
|
| 206 |
+
"host_is_superhost": 1,
|
| 207 |
+
"host_thumbnail_url": 1,
|
| 208 |
+
"host_picture_url": 1,
|
| 209 |
+
"host_neighbourhood": 1,
|
| 210 |
+
"host_listings_count": 1,
|
| 211 |
+
"host_total_listings_count": 1,
|
| 212 |
+
"host_verifications": 1,
|
| 213 |
+
"host_has_profile_pic": 1,
|
| 214 |
+
"host_identity_verified": 1,
|
| 215 |
+
"neighbourhood": 1,
|
| 216 |
+
"neighbourhood_cleansed": 1,
|
| 217 |
+
"neighbourhood_group_cleansed": 1,
|
| 218 |
+
"latitude": 1,
|
| 219 |
+
"longitude": 1,
|
| 220 |
+
"property_type": 1,
|
| 221 |
+
"room_type": 1,
|
| 222 |
+
"accommodates": 1,
|
| 223 |
+
"bathrooms": 1,
|
| 224 |
+
"bathrooms_text": 1,
|
| 225 |
+
"bedrooms": 1,
|
| 226 |
+
"beds": 1,
|
| 227 |
+
"amenities": 1,
|
| 228 |
+
"price": 1,
|
| 229 |
+
"minimum_nights": 1,
|
| 230 |
+
"maximum_nights": 1,
|
| 231 |
+
"minimum_minimum_nights": 1,
|
| 232 |
+
"maximum_minimum_nights": 1,
|
| 233 |
+
"minimum_maximum_nights": 1,
|
| 234 |
+
"maximum_maximum_nights": 1,
|
| 235 |
+
"minimum_nights_avg_ntm": 1,
|
| 236 |
+
"maximum_nights_avg_ntm": 1,
|
| 237 |
+
"calendar_updated": 1,
|
| 238 |
+
"has_availability": 1,
|
| 239 |
+
"availability_30": 1,
|
| 240 |
+
"availability_60": 1,
|
| 241 |
+
"availability_90": 1,
|
| 242 |
+
"availability_365": 1,
|
| 243 |
+
"calendar_last_scraped": 1,
|
| 244 |
+
"number_of_reviews": 1,
|
| 245 |
+
"number_of_reviews_ltm": 1,
|
| 246 |
+
"number_of_reviews_l30d": 1,
|
| 247 |
+
"first_review": 1,
|
| 248 |
+
"last_review": 1,
|
| 249 |
+
"review_scores_rating": 1,
|
| 250 |
+
"review_scores_accuracy": 1,
|
| 251 |
+
"review_scores_cleanliness": 1,
|
| 252 |
+
"review_scores_checkin": 1,
|
| 253 |
+
"review_scores_communication": 1,
|
| 254 |
+
"review_scores_location": 1,
|
| 255 |
+
"review_scores_value": 1,
|
| 256 |
+
"license": 1,
|
| 257 |
+
"instant_bookable": 1,
|
| 258 |
+
"calculated_host_listings_count": 1,
|
| 259 |
+
"calculated_host_listings_count_entire_homes": 1,
|
| 260 |
+
"calculated_host_listings_count_private_rooms": 1,
|
| 261 |
+
"calculated_host_listings_count_shared_rooms": 1,
|
| 262 |
+
"reviews_per_month": 1,
|
| 263 |
+
"description_embedding": 0
|
| 264 |
}
|
| 265 |
}
|
| 266 |
|