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

如何在聊天机器人回复中添加喜欢和不喜欢按钮? #861

Closed
1 task done
nguyenquocduongqnu opened this issue Aug 17, 2023 · 5 comments
Closed
1 task done
Labels
feature request New feature or request

Comments

@nguyenquocduongqnu
Copy link

相关问题

我想在聊天机器人的回复内容中自定义添加喜欢和不喜欢按钮,如图所示。 你能给我解决方案吗? 谢谢

Untitled

可能的解决办法

我想在聊天机器人的回复内容中自定义添加喜欢和不喜欢按钮,如图所示。 你能给我解决方案吗? 谢谢

Untitled

帮助开发

  • 我愿意协助开发!

补充说明

No response

@nguyenquocduongqnu nguyenquocduongqnu added the feature request New feature or request label Aug 17, 2023
@Keldos-Li
Copy link
Collaborator

Keldos-Li commented Aug 17, 2023

I'm glad to see that you used our program as prototype (and even opened the same issue in gradio-app/gradio#5250...)

In fact, this is feasible to some extent, for example, we have like and dislike buttons for the XMChat model. If you need to add it to the conversation message elements, you just need to write a little more JavaScript.

The question is, what do you want to do with the back end of the click event? We haven't imported FastAPI yet, and of course, it's possible to use js to write the whole event handling.

Maybe we should also consider adding extension functions..

@nguyenquocduongqnu
Copy link
Author

We want to create a feature to rate feedback.

We use mongo db to statistic like or dislike from user feedback. I want to display these 2 buttons in the response from chatbot, can you suggest me the direction. Thank you

@Keldos-Li
Copy link
Collaborator

OK, I will explain this in short:

  1. Use gradio to add like and dislike buttons anywhere you like, and bind functions to them. If you want, set visible=False.
  2. Use javascript (with HTML and CSS) to create custom like and dislike buttons, and use mutation observer to add them to messages when popped.
  3. Add js functions to your custom buttons, and bind click event with the click events of gradio buttons.
  4. Done! You can make everything prettier now.

The direction is simple, right?

I'm really thinking about extention methods now...

@nguyenquocduongqnu
Copy link
Author

OK, I will explain this in short:

  1. Use gradio to add like and dislike buttons anywhere you like, and bind functions to them. If you want, set visible=False.
  2. Use javascript (with HTML and CSS) to create custom like and dislike buttons, and use mutation observer to add them to messages when popped.
  3. Add js functions to your custom buttons, and bind click event with the click events of gradio buttons.
  4. Done! You can make everything prettier now.

The direction is simple, right?

I'm really thinking about extention methods now...

Thank you very much. I will try.

@Keldos-Li
Copy link
Collaborator

Keldos-Li commented Sep 6, 2023

The outcome is actually something like this:

image

I will close this issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants