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 Feedback Buttons Dynamically to All AI Responses in Chat Component #330

Open
Nithiya2223 opened this issue Jan 7, 2025 · 1 comment
Assignees
Labels
advice Information how to use/implement the component

Comments

@Nithiya2223
Copy link

Hi ,
I have just gone through the docs. I could see that the feedback buttons can be added to the demo chat like

ngAfterViewInit(){
if (this.chatElementRef?.nativeElement) {
this.chatElementRef.nativeElement.demo = {
response: {
html: <div class="feedback"> <img class="feedback-icon feedback-icon-positive" src="path-to-svg.svg"> <img class="feedback-icon feedback-icon-negative" src="path-to-svg.svg"> </div>,
},
};
this.chatElementRef.nativeElement.htmlClassUtilities = {
feedback: {styles: {default: {display: 'flex'}}},
'feedback-text': {styles: {default: {width: 'calc(100% - 42px)', paddingTop: '2px'}}},
'feedback-icon': {
styles: {
default: {width: '20px', height: '20px', cursor: 'pointer', borderRadius: '5px'},
hover: {backgroundColor: '#d1d1d1'},
},
},
'feedback-icon-positive': {events: {click: () => console.log('positive response')}},
'feedback-icon-negative': {
events: {click: () => console.log('negative response')},
styles: {default: {transform: 'rotate(180deg)', marginLeft: '3px'}},
},
};
}
} this adds feedback button for demo responses
When connected to a server how to add those feedback button to all the messages from ai .
I'm using angular framework.

@OvidijusParsiunas
Copy link
Owner

Hi @Nithiya2223.
If you are asking about how to wrap ai response text into messages that have the feedback button - you can go about it in many ways:

  • The natural way is to simply get your server to respond with the html property as:
{
    html: `
      <div class="feedback">
        <div class="feedback-text">Your text here.</div>
        <img class="feedback-icon feedback-icon-positive" src="path-to-svg.svg">
        <img class="feedback-icon feedback-icon-negative" src="path-to-svg.svg">
      </div>`
  }
}
  • If you cannot change your server responses, then you can use the responseInterceptor and augment the returned message to the syntax above.
  • If you are using a handler function, you should once again use the response signals with the syntax above.

Let me know if this helps. Thanks!

@OvidijusParsiunas OvidijusParsiunas self-assigned this Jan 8, 2025
@OvidijusParsiunas OvidijusParsiunas added the advice Information how to use/implement the component label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
advice Information how to use/implement the component
Projects
None yet
Development

No branches or pull requests

2 participants