mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-06-04 11:14:10 +08:00
fix weight rerank of knowledge retrieval (#10931)
This commit is contained in:
parent
82575a7aea
commit
cb0c55daa7
@ -27,11 +27,11 @@ class RerankModelRunner(BaseRerankRunner):
|
||||
:return:
|
||||
"""
|
||||
docs = []
|
||||
doc_id = set()
|
||||
doc_ids = set()
|
||||
unique_documents = []
|
||||
for document in documents:
|
||||
if document.provider == "dify" and document.metadata["doc_id"] not in doc_id:
|
||||
doc_id.add(document.metadata["doc_id"])
|
||||
if document.provider == "dify" and document.metadata["doc_id"] not in doc_ids:
|
||||
doc_ids.add(document.metadata["doc_id"])
|
||||
docs.append(document.page_content)
|
||||
unique_documents.append(document)
|
||||
elif document.provider == "external":
|
||||
|
@ -37,11 +37,10 @@ class WeightRerankRunner(BaseRerankRunner):
|
||||
:return:
|
||||
"""
|
||||
unique_documents = []
|
||||
doc_id = set()
|
||||
doc_ids = set()
|
||||
for document in documents:
|
||||
doc_id = document.metadata.get("doc_id")
|
||||
if doc_id not in doc_id:
|
||||
doc_id.add(doc_id)
|
||||
if document.metadata["doc_id"] not in doc_ids:
|
||||
doc_ids.add(document.metadata["doc_id"])
|
||||
unique_documents.append(document)
|
||||
|
||||
documents = unique_documents
|
||||
|
Loading…
x
Reference in New Issue
Block a user