Spaces:
Running
Running
Update custom_utils.py
Browse files- custom_utils.py +16 -0
custom_utils.py
CHANGED
|
@@ -133,6 +133,10 @@ def vector_search_naive(openai_api_key,
|
|
| 133 |
vector_index="vector_index"):
|
| 134 |
query_embedding = get_text_embedding(openai_api_key, prompt)
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
if query_embedding is None:
|
| 137 |
return "Invalid query or embedding generation failed."
|
| 138 |
|
|
@@ -146,12 +150,20 @@ def vector_search_naive(openai_api_key,
|
|
| 146 |
}
|
| 147 |
}
|
| 148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
pipeline = [
|
| 150 |
vector_search_stage,
|
| 151 |
get_stage_include_fields(),
|
| 152 |
get_stage_filter_result(accomodates, bedrooms)
|
| 153 |
]
|
| 154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
return invoke_search(db, collection, pipeline)
|
| 156 |
|
| 157 |
def vector_search_advanced(openai_api_key,
|
|
@@ -322,6 +334,10 @@ def get_stage_sorting():
|
|
| 322 |
|
| 323 |
def invoke_search(db, collection, pipeline):
|
| 324 |
results = collection.aggregate(pipeline)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
|
| 326 |
#print(f"Vector search millis elapsed: {get_millis_elapsed(db, collection, pipeline)}")
|
| 327 |
|
|
|
|
| 133 |
vector_index="vector_index"):
|
| 134 |
query_embedding = get_text_embedding(openai_api_key, prompt)
|
| 135 |
|
| 136 |
+
print("###")
|
| 137 |
+
print(query_embedding)
|
| 138 |
+
print("###")
|
| 139 |
+
|
| 140 |
if query_embedding is None:
|
| 141 |
return "Invalid query or embedding generation failed."
|
| 142 |
|
|
|
|
| 150 |
}
|
| 151 |
}
|
| 152 |
|
| 153 |
+
print("###")
|
| 154 |
+
print(vector_search_stage)
|
| 155 |
+
print("###")
|
| 156 |
+
|
| 157 |
pipeline = [
|
| 158 |
vector_search_stage,
|
| 159 |
get_stage_include_fields(),
|
| 160 |
get_stage_filter_result(accomodates, bedrooms)
|
| 161 |
]
|
| 162 |
|
| 163 |
+
print("###")
|
| 164 |
+
print(pipeline)
|
| 165 |
+
print("###")
|
| 166 |
+
|
| 167 |
return invoke_search(db, collection, pipeline)
|
| 168 |
|
| 169 |
def vector_search_advanced(openai_api_key,
|
|
|
|
| 334 |
|
| 335 |
def invoke_search(db, collection, pipeline):
|
| 336 |
results = collection.aggregate(pipeline)
|
| 337 |
+
|
| 338 |
+
print("###")
|
| 339 |
+
print(results)
|
| 340 |
+
print("###")
|
| 341 |
|
| 342 |
#print(f"Vector search millis elapsed: {get_millis_elapsed(db, collection, pipeline)}")
|
| 343 |
|