Skip to content

Commit

Permalink
Backport PR jupyterlab#443: Ensure initials appear in collaborative mode
Browse files Browse the repository at this point in the history
  • Loading branch information
aychang95 authored and meeseeksmachine committed Nov 14, 2023
1 parent 2fdb5ba commit 0b46f24
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/jupyter-ai/jupyter_ai/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,19 @@ def get_chat_user(self) -> ChatUser:

if collaborative:
names = self.current_user.name.split(" ", maxsplit=2)
initials = "".join(
[(name.capitalize()[0] if len(name) > 0 else "") for name in names]
)
initials = getattr(self.current_user, "initials", None)
if not initials:
# compute default initials in case IdentityProvider doesn't
# return initials, e.g. JupyterHub (#302)
names = self.current_user.name.split(" ", maxsplit=2)
initials = "".join(
[(name.capitalize()[0] if len(name) > 0 else "") for name in names]
)
chat_user_kwargs = {
# set in case IdentityProvider doesn't return initials, e.g.
# JupyterHub (#302)
"initials": initials,
**asdict(self.current_user),
"initials": initials,
}

return ChatUser(**chat_user_kwargs)

login = getpass.getuser()
Expand Down

0 comments on commit 0b46f24

Please sign in to comment.