We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
gr.Chatbot
pip install https://gradio-pypi-previews.s3.amazonaws.com/936988dbbfd3cb1431ecd59fd7061e0217fe66f1/gradio-5.9.1-py3-none-any.whl
My Code is here:
import gradio as gr disliked_messages = {} def greet(history, user_input): return history + [{"role": "user", "content": user_input}, {"role": "assistant", "content": "Hello, " + user_input}], gr.update(value="") def vote(data: gr.LikeData, history): print(data.index, data.liked) if isinstance(data.index, int): message = history[data.index]["content"] else: message = "" if disliked_messages.get(message, False): # dislike -> cancel dislike disliked_messages[message] = False print("You canceled the dislike for this response: " + message) else: disliked_messages[message] = True print("You disliked this response: " + message) updated_history = [ {"role": item["role"], "content": item["content"]} if disliked_messages.get(item["content"], False) else item for item in history ] return gr.update(value=updated_history) with gr.Blocks() as demo: chatbot = gr.Chatbot(feedback_options=["Dislike"], type="messages") textbox = gr.Textbox() textbox.submit(greet, [chatbot, textbox], [chatbot, textbox]) chatbot.like(vote, [chatbot], chatbot) if __name__ == "__main__": demo.launch()
No matter how I modify the vote function, when I click on "thumb-down" again, "Dislike" cannot be canceled.
When I click “thumb-down” ,it turn to
and if I click “thumb-down” again, it turn to
but now:
The text was updated successfully, but these errors were encountered:
@abidlabs Thank you , That's really cool
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
I installed the newest version:
My Code is here:
No matter how I modify the vote function, when I click on "thumb-down" again, "Dislike" cannot be canceled.
When I click “thumb-down” ,it turn to
and if I click “thumb-down” again, it turn to
but now:
The text was updated successfully, but these errors were encountered: