Skip to content

Commit 2baa3f8

Browse files
committed
Scope import logic more tightly for persona files.
Only match (case insensitively) Python files with `persona` in the name.
1 parent b9ced2b commit 2baa3f8

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
@@ -308,14 +308,15 @@ def load_persona_classes(self) -> list[type[BasePersona]]:
308308
self.log.info(f"Root directory does not exist: {self.root_dir}")
309309
return persona_classes
310310

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

314315
if not py_files:
315-
self.log.info(f"No Python files found in directory: {self.root_dir}")
316+
self.log.info(f"No Python files with 'persona' in the name found in directory: {self.root_dir}")
316317
return persona_classes
317318

318-
self.log.info(f"Found {len(py_files)} Python files in {self.root_dir}")
319+
self.log.info(f"Found {len(py_files)} Python files with 'persona' in the name in {self.root_dir}")
319320
self.log.info("PENDING: Loading persona classes from local Python files...")
320321
start_time_ns = time_ns()
321322

0 commit comments

Comments
 (0)