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 allow_file_downloads param to allow downloading image/video/audio media in chatbot #9905

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

hannahblair
Copy link
Collaborator

@hannahblair hannahblair commented Nov 5, 2024

Description

We were never (iiuc) showing the download button in media messages in chatbot. I'e added an allow_file_downloads (default is false) param in case it's not actually wanted by certain users. Let me know if there's a better solution here!

I've also tweaked the padding so that components dont have an unnecessary padding that only text needs (see screenshot).

base new
Screenshot 2024-11-05 at 16 22 21 Screenshot 2024-11-05 at 16 20 07

Closes: #9217

🎯 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 Nov 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/36266906f8b4253cc5b6d920d5b54b7d19641291/gradio-5.5.0-py3-none-any.whl

Install Gradio Python Client from this PR

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

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/36266906f8b4253cc5b6d920d5b54b7d19641291/gradio-client-1.7.1.tgz

Use Lite from this PR

<script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/36266906f8b4253cc5b6d920d5b54b7d19641291/dist/lite.js""></script>

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Nov 5, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

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

With the following changelog entry.

Add allow_file_downloads param to allow downloading image/video/audio media in 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.

padding: var(--spacing-sm) var(--spacing-xl);
border-color: var(--border-color-accent-subdued);
background-color: var(--color-accent-soft);
}
@media (max-width: 480px) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

didn't need this, dupe of .user earlier in the file

title={message.metadata.title}
expanded={is_last_bot_message([message], value)}
>
<div class="message-content">
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to apply padding only to text message content

Comment on lines -88 to -99
name="Chatbot with copy button"
args={{
show_copy_button: true
}}
/>

<Story
name="Chatbot with chat bubble full width disabled"
args={{
bubble_full_width: false
}}
/>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removing these stories and consolidating their variants with other stories to reduce snapshot usage

@freddyaboulton
Copy link
Collaborator

Nice! Is it possible to respect the show_download_button parameter passed to the component instead of adding a component to the chatbot? I'm confused as to why the download button shows up when passed to the component but only when like/dislike is enabled (quoting from the issue - haven't verified!)

Copy link
Collaborator

@aliabid94 aliabid94 left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for the cleanup also! In response to what the issue is saying, it's only if there is a like listener that it appears in the like row automatically. I think we should remove it from the like row, and have it on media by default?
Screenshot 2024-11-06 at 1 42 22 PM

@hannahblair
Copy link
Collaborator Author

hannahblair commented Nov 7, 2024

Thanks for reviewing @freddyaboulton and @aliabid94!

I think we should remove it from the like row, and have it on media by default?

Yeah I forgot about it in the lower panel! It seems our logic to check when to show the panel (show: show_like || show_retry || show_undo || show_copy_button) was incomplete. Nonetheless, I'll remove the param and we'll just apply it by default.

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 image does not have download button
5 participants