fix retrieve documents error for search without reranker
Browse files
climateqa/engine/chains/retrieve_documents.py
CHANGED
|
@@ -477,8 +477,10 @@ async def retrieve_documents(
|
|
| 477 |
docs_question_dict[key] = rerank_and_sort_docs(reranker,docs_question_dict[key],question)
|
| 478 |
else:
|
| 479 |
# Add a default reranking score
|
| 480 |
-
for
|
| 481 |
-
|
|
|
|
|
|
|
| 482 |
|
| 483 |
# Keep the right number of documents
|
| 484 |
docs_question, images_question = concatenate_documents(index, source_type, docs_question_dict, k_by_question, k_summary_by_question, k_images_by_question)
|
|
|
|
| 477 |
docs_question_dict[key] = rerank_and_sort_docs(reranker,docs_question_dict[key],question)
|
| 478 |
else:
|
| 479 |
# Add a default reranking score
|
| 480 |
+
for key in docs_question_dict.keys():
|
| 481 |
+
if isinstance(docs_question_dict[key], list) and len(docs_question_dict[key]) > 0:
|
| 482 |
+
for doc in docs_question_dict[key]:
|
| 483 |
+
doc.metadata["reranking_score"] = doc.metadata["similarity_score"]
|
| 484 |
|
| 485 |
# Keep the right number of documents
|
| 486 |
docs_question, images_question = concatenate_documents(index, source_type, docs_question_dict, k_by_question, k_summary_by_question, k_images_by_question)
|