Skip to content

Commit 5fd3508

Browse files
committed
Scope import logic more tightly for persona files.
Only match (case insensitively) Python files with `persona` in the name.
1 parent 9a89601 commit 5fd3508

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

packages/jupyter-ai/jupyter_ai/personas/persona_manager.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,15 @@ def load_persona_classes(self) -> list[type[BasePersona]]:
335335
self.log.info(f"Root directory does not exist: {self.root_dir}")
336336
return persona_classes
337337

338-
# Find all .py files in the root directory
339-
py_files = glob(os.path.join(self.root_dir, "*.py"))
338+
# Find all .py files in the root directory that contain "persona" in the name
339+
all_py_files = glob(os.path.join(self.root_dir, "*.py"))
340+
py_files = [f for f in all_py_files if "persona" in Path(f).stem.lower()]
340341

341342
if not py_files:
342-
self.log.info(f"No Python files found in directory: {self.root_dir}")
343+
self.log.info(f"No Python files with 'persona' in the name found in directory: {self.root_dir}")
343344
return persona_classes
344345

345-
self.log.info(f"Found {len(py_files)} Python files in {self.root_dir}")
346+
self.log.info(f"Found {len(py_files)} Python files with 'persona' in the name in {self.root_dir}")
346347
self.log.info("PENDING: Loading persona classes from local Python files...")
347348
start_time_ns = time_ns()
348349

0 commit comments

Comments
 (0)