[BUG] A dollar sign in the result of a chat message results in italics in some parts of the response
Describe the bug
If the chatbot message includes a dollar sign $, the text results become italic in a weird way.
To Reproduce Steps to reproduce the behavior:
- Build a chatflow where the result ends up with a dollar sign Here is an example prompt:
give me a response that includes a dollar sign, such as "bananas are at least $2 in Canada and $1 in the US"
Expected behavior The text you entered and the response should be regularly formatted, not adding italics.
Screenshots
Flow Any flow that uses any chatbot will generally work.
Cause appears to be use of remarkMath and rehypeMathjax in the react markdown use. The message could be cleansed before given, but that doesn't seem great. Ideally a central message class would be used that could offer a cleansed message, or this component has a hook to cleanse beforehand.
This is further complicated because the ChatEmbed repo seems to use something else as well but probably suffers the same (I didn't check), so there's at least 3 places where the code is somewhat duplicated but also different.
ChatEmbed repo is not using react-markdown, but will be in future, to have the markdown formatting. Any suggestion of cleansing method?
Not yet I'd have to investigate if there's any clean way to do it. Easiest way is to remove the math stuff, but I assume you put it there for a reason?
Also Bing Chat GPT suffers the exact same issue so I think this might be a common problem.
Yeah its to support some cases where LaTex is being returned in the response