fix(api/core/model_manager.py): Avoid mutation during iteration. (#6536)

This commit is contained in:
-LAN-
2024-07-22 22:58:22 +08:00
committed by GitHub
parent 617847e3c0
commit cd7fa8027a
5 changed files with 5 additions and 10 deletions

View File

@@ -38,11 +38,10 @@ class BaseKeyword(ABC):
raise NotImplementedError
def _filter_duplicate_texts(self, texts: list[Document]) -> list[Document]:
for text in texts:
for text in texts[:]:
doc_id = text.metadata['doc_id']
exists_duplicate_node = self.text_exists(doc_id)
if exists_duplicate_node:
# FIXME: Mutation to loop iterable `texts` during iteration
texts.remove(text)
return texts