Azure-Samples / azure-search-openai-demo

A sample app for the Retrieval-Augmented Generation pattern running in Azure, using Azure AI Search for retrieval and Azure OpenAI large language models to power ChatGPT-style and Q&A experiences.
https://azure.microsoft.com/products/search
MIT License
5.88k stars 4.02k forks source link

LaTeX rendering in chat interface #1833

Open ssjdan27 opened 1 month ago

ssjdan27 commented 1 month ago

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [X] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

N/A

Any log messages given by the failure

N/A

Expected/desired behavior

It would be pretty neat if this application was able to render LaTeX commands output by the LLM. This could be helpful if someone wants to use an app like this to study for math exams that have study guides or answer sheets in the form of a pdf. Or even for asking the LLM about a math formula in a large textbook.

OS and Version?

N/A

azd version?

N/A

Versions

N/A

Mention any other details that might be useful

Current output image

Desired appearance: image


Thanks! We'll be in touch soon.

pamelafox commented 1 month ago

To enable that, you would want to bring in a package like https://katex.org/ that can render LaTex and ensure that your prompt results in properly formatted LaTeX. Then you can run katex on the resulting text and turn it into math. This PR would be similar to how you'd do it: https://github.com/Azure-Samples/azure-search-openai-demo/pull/56

We wouldn't want to do that for everyone, however, since that would increase the JavaScript load for a feature that most do not need. If you end up doing it, please share the code here so that others can benefit.