fix(api/core/model_manager.py): Avoid mutation during iteration. (#6536)
This commit is contained in:
parent
617847e3c0
commit
cd7fa8027a
5 changed files with 5 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue