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
11 changes: 7 additions & 4 deletions packages/jupyter-ai/jupyter_ai/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,17 @@ def get_chat_user(self) -> ChatUser:

if collaborative:
names = self.current_user.name.split(" ", maxsplit=2)
initials = "".join(
# set in case IdentityProvider doesn't return initials, e.g.
# JupyterHub (#302)
default_initials = "".join(
[(name.capitalize()[0] if len(name) > 0 else "") for name in names]
)
current_user_initials = getattr(self.current_user, "initials", None)
dlqqq marked this conversation as resolved.
Show resolved Hide resolved
chat_user_kwargs = {
# set in case IdentityProvider doesn't return initials, e.g.
# JupyterHub (#302)
"initials": initials,
**asdict(self.current_user),
"initials": current_user_initials
if current_user_initials
else default_initials,
}
return ChatUser(**chat_user_kwargs)

Expand Down
Loading