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

Chatbot: limit width of chat bubbles to be the size of the messages #4420

Closed
lucasjinreal opened this issue Jun 5, 2023 · 13 comments · Fixed by #5334
Closed

Chatbot: limit width of chat bubbles to be the size of the messages #4420

lucasjinreal opened this issue Jun 5, 2023 · 13 comments · Fixed by #5334
Assignees
Labels
enhancement New feature or request

Comments

@lucasjinreal
Copy link

lucasjinreal commented Jun 5, 2023

Is there a way to add max width constraints to bubbles containing the messages?

image

@abidlabs
Copy link
Member

abidlabs commented Jun 5, 2023

Hi @lucasjinreal what do you mean by bubbles? Can you please provide example code to repro and explain what you are getting vs. what you are expecting?

@abidlabs abidlabs added the needs repro Awaiting full reproduction label Jun 5, 2023
@lucasjinreal
Copy link
Author

@abidlabs Hello, its about ChatBot UI component.

  1. As you can see, the bubbles in both incoming and outcoming are have a large free space:

image

Would it better to make it fit automatically to content just like iMessages?

  1. My bottom have a TextBox and a Button, how can I make it align vertically?

@abidlabs abidlabs changed the title Chatbot UI add max width for bubbles Chatbot UI add max width for messages Jun 6, 2023
@abidlabs
Copy link
Member

abidlabs commented Jun 6, 2023

Thanks for the clarification, @lucasjinreal I've renamed the issue to reflect #1, it's something we'll think about!

@abidlabs abidlabs added enhancement New feature or request and removed needs repro Awaiting full reproduction labels Jun 6, 2023
@lucasjinreal
Copy link
Author

@abidlabs thank u.

I just find a repo using gradio made it, do u know what code they possible use? (nevertheless you are the creator of gradio!)

261efb275be94aec0368d4af46ed364

as you can see, their incoming bubble of mine, is limited width

@abidlabs
Copy link
Member

abidlabs commented Jun 7, 2023

@abidlabs abidlabs changed the title Chatbot UI add max width for messages Chatbot: limit width of chat bubbles to be the size of the messages Jun 7, 2023
@yvrjsharma
Copy link
Collaborator

Hi @lucasjinreal, in case you are still trying to figure out the solution, you can use custom CSS to limit the width of chatbot bubbles to the text size. We have addressed this query on our Discord server here if this is helpful - https://discord.com/channels/879548962464493619/1115927377277628517/1115927377277628517

@1ittlesnow
Copy link

with gr.Blocks( title="Chat with Open Large Language Models", theme=gr.themes.Base(), css=block_css, ) as demo:
When you create Blocks, there is a block_css. Ctrl click it.
Change 'block_css'.
Add [data-testid = "bot"] and [data-testid = "user"].
The property 'max_width' is its limit width of chat bubbles.

block_css = ( code_highlight_css + """ pre { white-space: pre-wrap; /* Since CSS 2.1 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; /* Internet Explorer 5.5+ */ } #notice_markdown th { display: none; } #notice_markdown td { padding-top: 8px; padding-bottom: 8px; } #leaderboard_markdown td { padding-top: 8px; padding-bottom: 8px; } """ )

block_css = ( code_highlight_css + """ pre { white-space: pre-wrap; /* Since CSS 2.1 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; /* Internet Explorer 5.5+ */ } #notice_markdown th { display: none; } #notice_markdown td { padding-top: 8px; padding-bottom: 8px; } #leaderboard_markdown td { padding-top: 8px; padding-bottom: 8px; } [data-testid = "bot"] { max-width: 75%; width: auto !important; border-bottom-left-radius: 0 !important; } [data-testid = "user"] { max-width: 75%; width: auto !important; border-bottom-right-radius: 0 !important; } """ )

@abidlabs
Copy link
Member

abidlabs commented Jul 5, 2023

Thanks @1ittlesnow for the custom css.

We may add it at some point as an option within the chatbot but not a priority right now since there's a workaround. (cc @dawoodkhan82)

@dawoodkhan82
Copy link
Collaborator

@abidlabs @1ittlesnow We might not add an option to adjust the chat bubble width. But one this we are considering is allowing devs to choose from a few select chatbot styles. One of these styles would include a chatbot where the bubbles are only as wide as the message (along with other style changes).

@abidlabs
Copy link
Member

abidlabs commented Jul 6, 2023

Just brainstorming here, but wouldn't it be better to have separate parameters for these options in case someone wants to stick to the default style but have limited-width bubbles?

@dawoodkhan82
Copy link
Collaborator

dawoodkhan82 commented Jul 6, 2023

Since removing the style() method, we would have to add this as a param to the init of chatbot or maybe as a theme var? But not completely convinced we want to expose changing things like height/width. Thoughts @pngwn?

@abidlabs abidlabs added this to the Component Cleanup milestone Jul 9, 2023
@austinmw
Copy link

austinmw commented Aug 4, 2023

Would look nicer IMO if the chat bubbles only extended to the width of the message (from the left or right, depending on user/bot)

@Keldos-Li
Copy link
Contributor

I just find a repo using gradio made it, do u know what code they possible use? (nevertheless you are the creator of gradio!)

261efb275be94aec0368d4af46ed364 as you can see, their incoming bubble of mine, is limited width

Apologize for following up on comments under an issue that hasn't seen new progress for quite some time. However, in fact, as shown in this image, Baize used the code from our ChuanhuChat project to build this demo:

image

@lucasjinreal You can review our project code here: https://github.com/GaiZhenbiao/ChuanhuChatGPT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants