Skip to content

Commit

Permalink
fix potential NoneType error
Browse files Browse the repository at this point in the history
  • Loading branch information
seehi committed May 6, 2024
1 parent f201b2f commit d4c0678
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions metagpt/rag/retrievers/bm25_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ def add_nodes(self, nodes: list[BaseNode], **kwargs) -> None:
self._corpus = [self._tokenizer(node.get_content()) for node in self._nodes]
self.bm25 = BM25Okapi(self._corpus)

self._index.insert_nodes(nodes, **kwargs)
if self._index:
self._index.insert_nodes(nodes, **kwargs)

def persist(self, persist_dir: str, **kwargs) -> None:
"""Support persist."""
self._index.storage_context.persist(persist_dir)
if self._index:
self._index.storage_context.persist(persist_dir)

0 comments on commit d4c0678

Please sign in to comment.