-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Feat(front): separate author and avatar; Add easy backend function #2509
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
base: main
Are you sure you want to change the base?
Conversation
@lamylio I'm assuming you're doing something like this: msg = cl.Message(author="GPT")
await msg.stream_token(chunk) But your issue here and in #2501 can be solved like this: msg = await cl.Message(author="GPT").send()
await msg.stream_token(chunk) Maybe the docs just need to be updated to make this clearer? If not please share your use case and code. |
I updated the documentation to fix the example here. @asvishnyakov @sandangel review/merge? |
Hey, thanks for the reply. Yeah I know and I agree with you, actually never had the issue in my case.
and by "coincidence" (😉) could "solve" the #2501 issue, by offering another possibility : msg = await cl.Message()
await msg.set_author_and_avatar(author="GPT") I admit the |
@lamylio I'd be ok with the frontend modification only, although I don't see how this will change any behavior or what the benefit is outside of making it clearer what's happening. Can you share why you want this? |
Currently doing this : await Message(
content="Hello :)",
author="Personal Assistant",
metadata={"avatarName": "robot"},
).send() Which is a useful use case, and better match the behavior it should have, imo. |
@lamylio gotcha. Yes please remove the other changes and also please make a PR in https://github.com/Chainlit/docs with this great example code. Thanks! |
This PR is stale because it has been open for 14 days with no activity. |
Motivation: #2501
Currently, the message avatar is either displayed from the author name or the miscellaneous and undocumented
metadata.avatarName
and requires the user to know he needs to.send()
the message for it to have an effect.Also, if
metadata.avatarName
is set, then the frontend ToolTip falsely displays the avatarName instead of the author.This PR aims to :
Backend:
Add new
set_author_and_avatar
method to the message API, allowing dynamic updates to both the author and avatar, demystifying the process.Frontend:
Refactor the avatar display logic to separate author and avatar handling, with a fallback to the author's name if the avatar is not defined (as this is currently the case).