Skip to content
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

Ensure initials appear in collaborative mode #443

Merged
merged 9 commits into from
Nov 14, 2023
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 @@ -121,15 +121,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,
dlqqq marked this conversation as resolved.
Show resolved Hide resolved
}

return ChatUser(**chat_user_kwargs)

login = getpass.getuser()
Expand Down
Loading