Spaces:
Running
Running
Update custom_utils.py
Browse files- custom_utils.py +2 -24
custom_utils.py
CHANGED
|
@@ -102,11 +102,7 @@ def rag_inference(openai_api_key, prompt, retrieval_result):
|
|
| 102 |
f"Question: {prompt}\n"
|
| 103 |
"Helpful Answer: "
|
| 104 |
)
|
| 105 |
-
|
| 106 |
-
print("###")
|
| 107 |
-
print(content)
|
| 108 |
-
print("###")
|
| 109 |
-
|
| 110 |
return invoke_llm(openai_api_key, content)
|
| 111 |
|
| 112 |
def invoke_llm(openai_api_key, content):
|
|
@@ -137,10 +133,6 @@ def vector_search_naive(openai_api_key,
|
|
| 137 |
vector_index="vector_index"):
|
| 138 |
query_embedding = get_text_embedding(openai_api_key, prompt)
|
| 139 |
|
| 140 |
-
print("\n\n\n\n\n### Embedding:")
|
| 141 |
-
print(query_embedding)
|
| 142 |
-
print("###")
|
| 143 |
-
|
| 144 |
if query_embedding is None:
|
| 145 |
return "Invalid query or embedding generation failed."
|
| 146 |
|
|
@@ -154,22 +146,12 @@ def vector_search_naive(openai_api_key,
|
|
| 154 |
}
|
| 155 |
}
|
| 156 |
|
| 157 |
-
print("\n\n\n\n\n### Vector Search Stage:")
|
| 158 |
-
print(vector_search_stage)
|
| 159 |
-
print("###")
|
| 160 |
-
|
| 161 |
pipeline = [
|
| 162 |
vector_search_stage,
|
| 163 |
get_stage_include_fields(),
|
| 164 |
get_stage_filter_result(accomodates, bedrooms)
|
| 165 |
]
|
| 166 |
|
| 167 |
-
print("\n\n\n\n\n### DB, Collection, Pipeline:")
|
| 168 |
-
print(db)
|
| 169 |
-
print(collection)
|
| 170 |
-
print(pipeline)
|
| 171 |
-
print("###")
|
| 172 |
-
|
| 173 |
return invoke_search(db, collection, pipeline)
|
| 174 |
|
| 175 |
def vector_search_advanced(openai_api_key,
|
|
@@ -341,11 +323,7 @@ def get_stage_sorting():
|
|
| 341 |
def invoke_search(db, collection, pipeline):
|
| 342 |
results = collection.aggregate(pipeline)
|
| 343 |
|
| 344 |
-
print("
|
| 345 |
-
print(results)
|
| 346 |
-
print("###")
|
| 347 |
-
|
| 348 |
-
#print(f"Vector search millis elapsed: {get_millis_elapsed(db, collection, pipeline)}")
|
| 349 |
|
| 350 |
return list(results)
|
| 351 |
|
|
|
|
| 102 |
f"Question: {prompt}\n"
|
| 103 |
"Helpful Answer: "
|
| 104 |
)
|
| 105 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
return invoke_llm(openai_api_key, content)
|
| 107 |
|
| 108 |
def invoke_llm(openai_api_key, content):
|
|
|
|
| 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 |
}
|
| 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,
|
|
|
|
| 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 |
|
| 328 |
return list(results)
|
| 329 |
|