OvidijusParsiunas / deep-chat

Fully customizable AI chatbot component for your website
https://deepchat.dev
MIT License
1.43k stars 218 forks source link

Regenerate response with same prompt #107

Closed rvangari96 closed 7 months ago

rvangari96 commented 8 months ago

Hi, I need to regenerate a response with the same prompt used before. Please advise on how to do it.

image

OvidijusParsiunas commented 8 months ago

Hi @rvangari96.

There are a couple of ways this can be achieved. Here is sample code for two different ways - this is using React syntax but you can pretty much tailor it to your framework:

return ( <DeepChat ref={ref} request={{ handler: (_, signals) => { signalsRef = signals; signals.onOpen(); signals.newUserMessage.listener = () => { // insert logic to retrieve a response signals.onResponse({html: '

Text
'}); }; }, websocket: true, }} htmlClassUtilities={{ regenerate: { events: { click: () => { // insert logic to retrieve a new response signalsRef?.onResponse({ html: '
Response Text
', overwrite: true, }); }, }, }, }} /> );



Let me know if you have any questions.

Thanks!
OvidijusParsiunas commented 7 months ago

Closing this issue since there has been no further communication. Feel free to comment below for anything related to this issue or create a new one for other topics. Thankyou!