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

Tweak ChatMessage layout #7209

Merged
merged 6 commits into from
Sep 1, 2024
Merged

Tweak ChatMessage layout #7209

merged 6 commits into from
Sep 1, 2024

Conversation

ahuang11
Copy link
Contributor

@ahuang11 ahuang11 commented Aug 30, 2024

Ensures the icon divider is invisible if reaction_icons is empty or if copy icon is invisible.

import panel as pn

pn.extension()

cm = pn.chat.ChatMessage("ABC")
cm.servable()
image

cm = pn.chat.ChatMessage("ABC", show_copy_icon=False)

image

cm = pn.chat.ChatMessage("ABC", reaction_icons={})

image

@ahuang11 ahuang11 changed the title tweak chat message layout Tweak ChatMessage layout Aug 30, 2024
Copy link

codecov bot commented Aug 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.27%. Comparing base (647db1a) to head (eef89b9).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7209      +/-   ##
==========================================
+ Coverage   82.24%   82.27%   +0.02%     
==========================================
  Files         331      331              
  Lines       49420    49470      +50     
==========================================
+ Hits        40647    40699      +52     
+ Misses       8773     8771       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Aug 31, 2024

The green activity indicator is now in the right spot. I still see the divider icon though.

image

You can reproduce with

from asyncio import sleep

import panel as pn

ORSTED_AVATAR = "https://nationalmaglab.org/media/hdri02zb/hans-christian-oersted.png"
ASSISTANT = "Ørsted, AI Trading Assistant"

pn.chat.message.DEFAULT_AVATARS[ASSISTANT] = ORSTED_AVATAR
pn.chat.ChatMessage.show_reaction_icons = False

pn.extension(sizing_mode="stretch_width")


async def generate_response(contents, user, instance):
    text = ""
    for _ in range(0, 50):
        text += "ABCD "
        yield text
        await sleep(0.1)


# pylint: disable=line-too-long
chat_interface = pn.chat.ChatInterface(
    callback=generate_response,
    callback_user=ASSISTANT,
    widgets=pn.chat.ChatAreaInput(
        placeholder="Enter some text and click Send",
        auto_grow=True,
        max_length=20000,
    ),
)
chat_interface.send(
    """XYZ """ * 50,
    user=ASSISTANT,
    respond=False,
)

pn.template.FastListTemplate(
    main=[chat_interface],
    main_max_width="1200px",
    main_layout=None,
).servable()

Copy link
Collaborator

@MarcSkovMadsen MarcSkovMadsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described its almost perfect. The vertical bar is still there though.

@philippjfr
Copy link
Member

The line is not reproducible on my end, I think you forgot to pull.

@philippjfr
Copy link
Member

Also we will have to revisit this, e.g. serializing a whole model simply to render the separator icon is a little bit insane.

@philippjfr philippjfr merged commit cf8fd2e into main Sep 1, 2024
16 checks passed
@philippjfr philippjfr deleted the tweak_chat_message_layout branch September 1, 2024 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants