Skip to content

Commit

Permalink
Backport PR #443: Ensure initials appear in collaborative mode (#468)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Chang <[email protected]>
  • Loading branch information
meeseeksmachine and aychang95 authored Nov 14, 2023
1 parent 2fdb5ba commit 4b7d076
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 4b7d076

Please sign in to comment.