Skip to content

Commit b4f4369

Browse files
Remove error log emitted when FAISS file is absent (#1287)
* Update `/learn.py` to log missing vector store * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8ce4fb5 commit b4f4369

File tree

1 file changed

+12
-6
lines changed
  • packages/jupyter-ai/jupyter_ai/chat_handlers

1 file changed

+12
-6
lines changed

packages/jupyter-ai/jupyter_ai/chat_handlers/learn.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,18 @@ def _load(self):
115115
if not embeddings:
116116
return
117117

118-
self.index = FAISS.load_local(
119-
INDEX_SAVE_DIR,
120-
embeddings,
121-
index_name=self.index_name,
122-
allow_dangerous_deserialization=True,
123-
)
118+
index_path = os.path.join(INDEX_SAVE_DIR, self.index_name + ".faiss")
119+
if os.path.exists(index_path):
120+
self.index = FAISS.load_local(
121+
INDEX_SAVE_DIR,
122+
embeddings,
123+
index_name=self.index_name,
124+
allow_dangerous_deserialization=True,
125+
)
126+
else:
127+
self.log.info(
128+
"No existing vector index found. You may create one using `/learn`."
129+
)
124130
self.load_metadata()
125131
except Exception as e:
126132
self.log.error(

0 commit comments

Comments
 (0)