Closed ittech17 closed 8 months ago
Hi @ittech17.
Deep Chat uses the Remarkable library to automatically format text responses. It appears you are using html responses which Deep Chat does not format as their syntax is fully controlled by the developers.
Fortunately when you install Deep Chat in your app, Remarkable is automatically installed with it, meaning that you can format the text from your app. All you need to do is the following:
import {Remarkable} from 'remarkable';
If you are using TypeScript you may also need to install the type package:
npm i --save-dev @types/remarkable
responseInterceptor
, you can use something like the following code where Remarkable is first instantiated and then used to format the text:
(response) => {
const remarkable = new Remarkable({
highlight: (str) => {
return str;
},
linkTarget: '_blank',
});
const text = remarkable.render(response.text);
return {
html: `<div class="feedback">
<div class="feedback-text">${text}</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>`,
};
}
Tip: Depending on the framework of your choice - you can instantiate remarkable on startup once and reuse its reference in the responseInterceptor
.
Let me know if you need any further help!
I will be closing this issue as there has been no further communication on this issue. If you have any other questions in the context of this issue, feel free to comment below. For everything else, feel free to create a new issue. Thanks!
Hi,
Thanks for the amazing product.
I have a query (and others might also face this issue):
The response I get from openAI is multi line , but it always shows as a single paragraph in chat window. I workaround it by wrapping it in HTML, and add
<br>
in responseInterceptor.Can you please suggest a better way ?