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

Allow editing chatbot messages #10203

Merged
merged 16 commits into from
Dec 19, 2024
Merged

Allow editing chatbot messages #10203

merged 16 commits into from
Dec 19, 2024

Conversation

aliabid94
Copy link
Collaborator

@aliabid94 aliabid94 commented Dec 15, 2024

Adds the ability to edit chatbot messages. See below:
Recording 2024-12-15 at 12 41 27

In a followup PR, I still need to:

  • Allow editing non-text messages (images, etc.)
  • Add editing to ChatInterface by default
  • When messages are grouped, allow editing other then the last message

Closes: #7919

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Dec 15, 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/3c7a6885eabf1171b59c125703c2cf627938cf64/gradio-5.9.1-py3-none-any.whl

Install Gradio Python Client from this PR

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

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/3c7a6885eabf1171b59c125703c2cf627938cf64/gradio-client-1.8.0.tgz

Use Lite from this PR

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

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Dec 15, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

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

With the following changelog entry.

Allow editing chatbot messages

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.

Ali Abid added 2 commits December 15, 2024 13:15

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

Nice @aliabid94 - works well and the e2e is great. Just left some nits on the editing textbox size

@abidlabs
Copy link
Member

Very nice UI @aliabid94! Left a comment on the parameter above. I'd also suggest we document this in https://www.gradio.app/guides/creating-a-custom-chatbot-with-blocks

Ali Abid added 4 commits December 18, 2024 15:53

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@aliabid94
Copy link
Collaborator Author

Ready for re-review and merge @abidlabs

Ali Abid added 3 commits December 18, 2024 17:02

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@@ -133,6 +133,22 @@ def handle_like(data: gr.LikeData):
chatbot.like(vote, None, None)
```

## The Edit Event

Same idea with the edit listener! with `gr.Chatbot(editable=True)`, you can capture user edits as such:
Copy link
Member

Choose a reason for hiding this comment

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

I think editable chatbots deserves a bigger section than just this in the docs!

Suggested change
Same idea with the edit listener! with `gr.Chatbot(editable=True)`, you can capture user edits as such:
Same idea with the edit listener! with `gr.Chatbot(editable=True)`, you can capture user edits as such:

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.

Looks great to me! Left a few minor comments

aliabid94 and others added 3 commits December 19, 2024 15:30
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
@aliabid94 aliabid94 enabled auto-merge (squash) December 19, 2024 23:34
@aliabid94 aliabid94 merged commit c3a9e64 into main Dec 19, 2024
22 of 23 checks passed
@aliabid94 aliabid94 deleted the chatbot_editing branch December 19, 2024 23:54
freddyaboulton pushed a commit that referenced this pull request Dec 23, 2024
* changes

* add changeset

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* Update gradio/events.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Update gradio/components/chatbot.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* changes

---------

Co-authored-by: Ali Abid <aliabid94@gmail.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
freddyaboulton added a commit that referenced this pull request Dec 23, 2024
* update code

* modify imports

* fix

* update notebook

* gr.load_chat: Allow loading any openai-compatible server immediately as a ChatInterface (#10222)

* changes

* add changeset

* add changeset

* Update gradio/external.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* changes

* changes

* Update guides/05_chatbots/01_creating-a-chatbot-fast.md

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* changes

---------

Co-authored-by: Ali Abid <aliabid94@gmail.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Allow editing chatbot messages (#10203)

* changes

* add changeset

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* Update gradio/events.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Update gradio/components/chatbot.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* changes

---------

Co-authored-by: Ali Abid <aliabid94@gmail.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Update Guides related to deploying Gradio chatbots to Discord, Slack, and website widgets (#10221)

* changes

* changes

* update

* chat history

* add changeset

* changes

* add changeset

* changes

* guide

* changes

* changes

* changes

* guide

* add images

* slack guide

* changes

* format

* add changeset

* finish up slack

* changes

* improve js guide

* update

* changes

* script

* changes

* changes

* add changeset

* Update guides/05_chatbots/01_creating-a-chatbot-fast.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* Update guides/05_chatbots/01_creating-a-chatbot-fast.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* Update guides/05_chatbots/06_creating-a-discord-bot-from-a-gradio-app.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* Update guides/05_chatbots/08_creating-a-website-widget-from-a-gradio-chatbot.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* Update guides/05_chatbots/08_creating-a-website-widget-from-a-gradio-chatbot.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* gradio

* cta

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* Allow editable ChatInterface (#10229)

* changes

* add changeset

* changes

* changes

* changes

---------

Co-authored-by: Ali Abid <aliabid94@gmail.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Fix typing for components in `gr.Interface` and docstring in `image.py` (#10235)

* changes

* add changeset

* changes

* changes

* change

* add changeset

* image.py

* revert msg

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Lite: Capture stdout and stderr from the main thread (#9984)

* Add stdout and stderr events

* add changeset

* Refactoring

* Format App.tsx

* add changeset

* Add python-error event to capture Python errors occurring in the running event loop after the initial app launch

* Fix <ErrorDisplay />'s close button

* Fix <ErrorDisplay />

* Propagate python-error and initialization-error events to the controller

* Add init-code|file-run-error events

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* use chat interface

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: aliabid94 <aabid94@gmail.com>
Co-authored-by: Ali Abid <aliabid94@gmail.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
Co-authored-by: Yuichiro Tachibana (Tsuchiya) <t.yic.yt@gmail.com>
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.

Allow editing of messages in Chatbot
4 participants