gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
33.42k stars 2.53k forks source link

Allow persisting upvote/downvote #6755

Closed cosmosof closed 9 months ago

cosmosof commented 10 months ago

Is your feature request related to a problem? Please describe.
Users are allowed to vote outputs, I am saving this into the DB, however I can't find a way to display back on each chat items.

Describe the solution you'd like
We should be able to display back vote data when user loads back to the same chat

abidlabs commented 9 months ago

Hi @cosmosof this is out of scope of the gr.Chatbot component. The reason is that we do not save the state of components, only their value. There is no way in Gradio to reproduce specific user interactions with a component that does not change its core value. I.e. this would be like us trying to display back what parts of a text were highlighted by a user in a gr.Textbox.

Although it is out of scope of gr.Chatbot, I think this would be a great case for a custom component!

We've made it possible for Gradio users to create their own custom components -- meaning that you can write some Python and JavaScript (Svelte), and publish it as a Gradio component. You can use it in your own Gradio apps, or share it so that anyone can use it in their Gradio apps.

Here's an example of a Gradio custom component: https://github.com/PhyscalX/gradio-image-prompter -- it lets you upload images and process points or draw boxes on top of the image.

In your case, you could create a custom component very similar to gr.Chatbot that includes likes/dislikes as part of the value. If you'd like to create your own, we've put together a Guide: https://www.gradio.app/guides/five-minute-guide, and we're happy to help.