Skip to content

Load local personas from .jupyter/personas instead of .jupyter/ #1443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 12, 2025

Conversation

andrii-i
Copy link
Collaborator

@andrii-i andrii-i commented Aug 7, 2025

References

Fixes #1424

Code changes

Local personas are now loaded from personas subderectory of the .jupyter directory.

User-facing changes

If there are personas in .jupyter directory, send system chat message warning users that they should be moved to the personas sub-directory.

Screenshot 2025-08-07 at 5 45 43 PM

Other considerations

Taking into account that find_dot_dir function navigates up from the chat file location in search of .jupyter folder and therefore there could be multiple potential .jupyter locations, I considered showing the absolute path to .jupyter as a part of system message.

I decided against it to not overload casual users working in managed instances, power users already know which .jupyter directory contains their personas, and detailed information about where AiExtension is searching for persona files is available in terminal logs:

[I 2025-08-07 17:45:05.236 AiExtension] Searching for persona files in /Users/Documents/nnbs/.jupyter

@andrii-i andrii-i added the enhancement New feature or request label Aug 7, 2025
@andrii-i
Copy link
Collaborator Author

andrii-i commented Aug 7, 2025

Kicking CI

@andrii-i andrii-i closed this Aug 7, 2025
@andrii-i andrii-i reopened this Aug 7, 2025
@andrii-i andrii-i marked this pull request as ready for review August 8, 2025 00:46
Copy link
Collaborator

@srdas srdas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this as follows:

  1. Added the emoji persona files to the .jupyter/personas/ subfolder and started a new chat session. The persona displays with the @EmojiPersona prefix. The commands also execute as expected with this persona.
  2. Deleting these files and opening a new chat reveals no emoji persona as expected.
  3. Also checked that using /refresh-personas in chat either adds or deletes the persona as expected.

The code looks good to me.

One thing to be handled in a separate PR is to allow subfolders for each persona under the .jupyter/personas/ subfolder. This is because every persona contains a persona.py file and hence all personas cannot be in one single .jupyter/personas/ subfolder. This is true for any personas that have common filenames. We also need to add documentation to (i) explain where the files need to be placed, (ii) explain that the dependencies also need to be installed if the persona is just being "dropped in".

@andrii-i andrii-i marked this pull request as ready for review August 11, 2025 17:12
Copy link
Member

@dlqqq dlqqq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, thank you Andrii!

My only concerns w/ this area of the code are pre-existing issues, so they don't need to be addressed here. Just calling them out:

  1. There is an added security risk with loading any module matching the glob .jupyter/personas/*persona*.py. We should explore whether we can be more secure by default.

  2. We are using the os and glob module to find persona files on the server's local filesystem. This will not work for Jupyter users with a custom/remote ContentsManager configured in their Jupyter Server.

@dlqqq dlqqq changed the title Load local personas from personas subdirectory of .jupyter directory Load local personas from .jupyter/personas instead of .jupyter/ Aug 11, 2025
@andrii-i andrii-i merged commit f749896 into jupyterlab:main Aug 12, 2025
9 checks passed
@andrii-i andrii-i deleted the personas-subdir branch August 12, 2025 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Look for local personas in .jupyter/personas
3 participants