From 4664a0baa2993efb2b0265d41f376dd5c902c6c8 Mon Sep 17 00:00:00 2001 From: Sanjiv Das Date: Mon, 8 Jul 2024 12:04:17 -0700 Subject: [PATCH] Address error on `/learn` after change of embedding model (#870) * Address error on `/learn` after change of embedding model. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Set `all_files` option to default to False * [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> --- packages/jupyter-ai/jupyter_ai/chat_handlers/learn.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/jupyter-ai/jupyter_ai/chat_handlers/learn.py b/packages/jupyter-ai/jupyter_ai/chat_handlers/learn.py index e8ca6bddc..6b8105bd4 100644 --- a/packages/jupyter-ai/jupyter_ai/chat_handlers/learn.py +++ b/packages/jupyter-ai/jupyter_ai/chat_handlers/learn.py @@ -175,7 +175,7 @@ def _build_list_response(self): return message async def learn_dir( - self, path: str, chunk_size: int, chunk_overlap: int, all_files: bool + self, path: str, chunk_size: int, chunk_overlap: int, all_files: bool = False ): dask_client: DaskClient = await self.dask_client_future splitter_kwargs = {"chunk_size": chunk_size, "chunk_overlap": chunk_overlap} @@ -267,7 +267,9 @@ async def relearn(self, metadata: IndexMetadata): for dir in metadata.dirs: # TODO: do not relearn directories in serial, but instead # concurrently or in parallel - await self.learn_dir(dir.path, dir.chunk_size, dir.chunk_overlap) + await self.learn_dir( + dir.path, dir.chunk_size, dir.chunk_overlap, all_files=False + ) self.save()