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
commit cd7fa8027a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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