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

Add copy all messages button to chatbot #9013

Merged
merged 18 commits into from
Aug 12, 2024
Merged

Add copy all messages button to chatbot #9013

merged 18 commits into from
Aug 12, 2024

Conversation

hannahblair
Copy link
Collaborator

@hannahblair hannahblair commented Aug 5, 2024

Description

Adds a copy all button (via a show_copy_all_button param) similar to gr.JSON and other components. I'm curious to know if we think this should look more unique to the other copy buttons in Chatbot 🤔

Having other messages with copy buttons will look confusing, and scrolling will look terrible if users have copy buttons as well (which I've asked about in Slack)

We could use a clipboard icon:

Screenshot 2024-08-06 at 11 03 35

but then we're losing out on consistency between other components.

Also, should default be true or false?

Screenshot 2024-08-06 at 10 59 47

Test:

import gradio as gr

with gr.Blocks() as demo:
    gr.Chatbot(show_copy_all_button=True, show_copy_button=True, value=[["Hello World","Hey Gradio!"],["❤️","😍"],["🔥","🤗"]])

demo.launch()

Clipboard output:

user: Hello World

assistant: Hey Gradio!

user: ❤️

assistant: 😍

user: 🔥

assistant: 🤗

Closes: #7446

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Tests

  1. PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests: bash scripts/run_all_tests.sh

  2. You may need to run the linters: bash scripts/format_backend.sh and bash scripts/format_frontend.sh

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Aug 5, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/37141e9807203a720acfc0e4193936ec6f15cec6/gradio-4.41.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@37141e9807203a720acfc0e4193936ec6f15cec6#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/37141e9807203a720acfc0e4193936ec6f15cec6/gradio-client-1.5.0.tgz

@hannahblair hannahblair marked this pull request as draft August 5, 2024 22:46
pngwn and others added 6 commits August 5, 2024 23:57

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@hannahblair hannahblair marked this pull request as ready for review August 6, 2024 09:06
hannahblair and others added 6 commits August 6, 2024 10:06
 into chatbot-copy-msgs
@@ -172,6 +172,7 @@ def __init__(
likeable: bool = False,
layout: Literal["panel", "bubble"] | None = None,
placeholder: str | None = None,
show_copy_all_button=False,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
show_copy_all_button=False,
show_copy_all_button: bool = False,

Copy link
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

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

lgtm @hannahblair! tested, works great

I agree about using the same copy icon. The position of the icon is enough to signify that it copies all messages

hannahblair and others added 4 commits August 12, 2024 15:41
 into chatbot-copy-msgs
@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Aug 12, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/chatbot minor
@gradio/code minor
gradio minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Add copy all messages button to chatbot

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

Sorry, something went wrong.

@hannahblair hannahblair enabled auto-merge (squash) August 12, 2024 13:52
@hannahblair hannahblair merged commit 5350f1f into main Aug 12, 2024
18 checks passed
@hannahblair hannahblair deleted the chatbot-copy-msgs branch August 12, 2024 14:08
This was referenced Aug 11, 2024
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.

Chatbot copy all messages
5 participants