azure-search-openai-demo
azure-search-openai-demo copied to clipboard
XML/HTML responses from OpenAI Chat don't render properly
Example prompt "provide me a short example of xml"
Tokens come back but don't render correctly in the application, only shows part of the response.
Hm. The UI is currently designed to render Markdown, never tested with XML.
This is the relevant component that renders the response:
const sanitizedAnswerHtml = DOMPurify.sanitize(parsedAnswer.answerHtml);
// later:
<div className={styles.answerText}>
<ReactMarkdown children={sanitizedAnswerHtml} rehypePlugins={[rehypeRaw]} remarkPlugins={[remarkGfm]} />
</div>
I think I can see the XML characters flashing by before they get removed, I am guessing that DOMPurify is removing them. You would need to change that code to see what would work well for your application. We could only make that change to the base application code if it was definitely safe, i.e. no risk of rendering unsafe HTML.