Skip to content

Commit 31ed11e

Browse files
Backport PR #747: Fix /learn in 2.14.0 (#754)
Co-authored-by: michaelchia <michael_chia7@msn.com>
1 parent 13b47d0 commit 31ed11e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/jupyter-ai/jupyter_ai/document_loaders/directory.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def split(path, all_files: bool, splitter):
6666

6767
# Check if the path points to a single file
6868
if os.path.isfile(path):
69-
dir = os.path.dirname(path)
70-
filenames = [os.path.basename(path)]
69+
filepaths = [Path(path)]
7170
else:
71+
filepaths = []
7272
for dir, subdirs, filenames in os.walk(path):
7373
# Filter out hidden filenames, hidden directories, and excluded directories,
7474
# unless "all files" are requested
@@ -77,9 +77,9 @@ def split(path, all_files: bool, splitter):
7777
d for d in subdirs if not (d[0] == "." or d in EXCLUDE_DIRS)
7878
]
7979
filenames = [f for f in filenames if not f[0] == "."]
80+
filepaths += [Path(os.path.join(dir, filename)) for filename in filenames]
8081

81-
for filename in filenames:
82-
filepath = Path(os.path.join(dir, filename))
82+
for filepath in filepaths:
8383
# Lower case everything to make sure file extension comparisons are not case sensitive
8484
if filepath.suffix.lower() not in {j.lower() for j in SUPPORTED_EXTS}:
8585
continue

0 commit comments

Comments
 (0)