-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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 Markdown Render Support to GPT completions #56
base: main
Are you sure you want to change the base?
Add Markdown Render Support to GPT completions #56
Conversation
@praveen-palanisamy approved this pull request. It is working as expected. |
Hi @kishorerv93 : Thank you for reviewing, testing and confirming that this PR works as expected and resolves your issue. We need a review from @jongio / @chuwik / @pablocastro or another core dev with write access to approve/merge this. |
bumping this so that @jongio / @chuwik / @pablocastro can review this to get it implemented. |
@praveen-palanisamy for me it doesn't seem to work properly. |
I suspect that the actual Markdown returned by the second question included backticks, and thats why the Markdown renders as code. Here's a deployed version which includes the markdown renderer: |
@pamelafox : Resolved the merge conflicts with the latest |
@praveen-palanisamy Thanks for updating to main! I've integrated this change in this demo app here to test it out: Now that we've added streaming to the repo, this change does introduce a slight visual hiccup when it's interpreting certain incremental Markdown, and some of those can be jarring. I screen capped it happening: Glitch - turned list item into a heading: Fixed a moment after - back into a normal list item: I haven't dug into precisely the underlying Markdown causing the glitch, but I think we'd want some solution before merging into main, to avoid that jarring effect. It looks like it may be related to citations, and we might need to make sure that citations get streamed a whole citation at a time, but I'm not certain that's the case. If you have time to look into it, let us know what you find out. |
cc @SteveJSteiner who authored the streaming change (see comment above on interaction with this PR) |
That's a good observation! If we have Markdown rendering enabled while streaming (partial fragments/chunks of) output text, that's an inevitable artifact, I think. I have observed this behavior with the official ChatGPT webapp and also with the Bing (Enterprise) Chat. A sample repro below where the partial markdown bold text takes a few more bytes to be complete and render properly. This output didn't include Markdown headers to match with your above screenshot, but you can see the behavior: StreamingMarkdownRender-BingChatEnterprise.mp4If this is an unacceptable UX, one way to handle this is to add another post-processing step in |
Yes, I have seen chatGPT with some visual ticks due to re-rendering of markdown. Table as the output hits this. I can also reproduce some oddities in Bing as well as it creates annotated lists. @pamelafox - what kind of bar do you wish to apply for these cases? Adding markdown support seems highly worthwhile. Can the markdown support be disabled if a user customizing the demo repo finds it too jarring for their end customers? Turing off the streaming in those cases is also an option. |
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed. |
@pamelafox : Could you please provide your final comments to finalize this PR soon? @microsoft-github-policy-service agree |
Okay, so I think what we could do is just change our CSS so that headings inside the chat boxes aren't actually very large, that way it isn't such a jarring visual glitch. How about that? |
Purpose
The frontend on the
main
branch currently doesn't support rendering Markdown in the model's responses/completions. This PR adds support for rendering Markdown while retaining support for raw HTML code in the completions.Fixes #30
Does this introduce a breaking change?
Pull Request Type
What kind of change does this Pull Request introduce?
How to Test
Run backend & frontend on Azure or locally and test with a prompt that would result in GPT's response/completion containing Markdown syntax. Example prompt:
What to Check
Verify that the UI renders Markdown syntax as expected.
Other Information
react-markdown
which is safe by default (nodangerouslySetInnerHTML
or XSS attacks)