Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -731,7 +731,6 @@ async def recipes_endpoint(profile: MedicalProfile):
|
|
731 |
f"{profile.conditions} and experiencing {profile.daily_symptoms}"
|
732 |
)
|
733 |
query_text = recipe_query
|
734 |
-
|
735 |
print(f"Generated query text: {query_text}")
|
736 |
|
737 |
# Generate the query embedding
|
@@ -745,15 +744,15 @@ async def recipes_endpoint(profile: MedicalProfile):
|
|
745 |
initial_results = query_recipes_embeddings(query_embedding, embeddings_data, n_results=10)
|
746 |
if not initial_results:
|
747 |
raise ValueError("No relevant recipes found.")
|
748 |
-
|
749 |
# Extract document IDs
|
750 |
document_ids = [doc_id for doc_id, _ in initial_results]
|
751 |
-
|
752 |
# Retrieve document texts
|
753 |
document_texts = retrieve_rec_texts(document_ids, folder_path)
|
754 |
if not document_texts:
|
755 |
raise ValueError("Failed to retrieve document texts.")
|
756 |
-
|
757 |
# Perform re-ranking with cross-encoder
|
758 |
cross_encoder = models['cross_encoder']
|
759 |
scores = cross_encoder.predict([(query_text, doc) for doc in document_texts])
|
|
|
731 |
f"{profile.conditions} and experiencing {profile.daily_symptoms}"
|
732 |
)
|
733 |
query_text = recipe_query
|
|
|
734 |
print(f"Generated query text: {query_text}")
|
735 |
|
736 |
# Generate the query embedding
|
|
|
744 |
initial_results = query_recipes_embeddings(query_embedding, embeddings_data, n_results=10)
|
745 |
if not initial_results:
|
746 |
raise ValueError("No relevant recipes found.")
|
747 |
+
print(initial_results)
|
748 |
# Extract document IDs
|
749 |
document_ids = [doc_id for doc_id, _ in initial_results]
|
750 |
+
print(document_ids)
|
751 |
# Retrieve document texts
|
752 |
document_texts = retrieve_rec_texts(document_ids, folder_path)
|
753 |
if not document_texts:
|
754 |
raise ValueError("Failed to retrieve document texts.")
|
755 |
+
print(document_texts)
|
756 |
# Perform re-ranking with cross-encoder
|
757 |
cross_encoder = models['cross_encoder']
|
758 |
scores = cross_encoder.predict([(query_text, doc) for doc in document_texts])
|