Skip to content

Enhancement: Mirror ChatGPT's equation rendering. #1469

@zyxir

Description

@zyxir

What features would you like to see added?

Add \(...\) and \[...\] delimiters for equation rendering, as in ChatGPT.

More details

First, I'd like to express my sincere gratitude to the developers for their exceptional work on LibreChat. As a STEM guy who frequently interacts with mathematical equations, I've recently encountered some unexpected behavior in this area. Upon closer examination, I discovered that:

  1. ChatGPT (chat.openai.com) pruduces equations surrounded by \(...\) and \[...\] by default. The Pictures section showcases how these equations are flawlessly displayed within ChatGPT's web interface.
  2. When called from the API, GPT 3.5 Turbo uses an unusual default format for equations. But upon request, it outputs equations using the same \(...\) and \[...\] delimiters as ChatGPT. To ensure LibreChat compatibility, GPT 3.5 Turbo's API must be explicitly prompted to use $...$ and $$...$$ for equation formatting, as dipicted in the Pictures section.

While adjusting the system prompt offers a workaround, \(...\) and \[...\] allow equations to coexist peacefully with the dollar sign's primary use as a currency symbol. That's likely why both ChatGPT and Org-mode embrace these delimiters. Since LibreChat claims to have a UI matching ChatGPT, matching equation rendering capabilities would be a fantastic improvement.

Additional information: Upon further investigatgion, I found that equation rendering is provided by rehype-katex and remark-math in LibreChat. rehype-katex renders math contents via KaTeX, while remark-math converts contents surrounded by dollar signs into math content. While exploring the issue list of remark-math, I stumbled upon this issue where the developer declined to implement \(...\) or \[...\] delimiters within the plugin. This may make the enhancement I propose harder or even impractical to implement. Therefore, I would appreciate the opportunity to discuss the significance and feasibility of the proposal with you.

Which components are impacted by your request?

UI

Pictures

Equation rendering within ChatGPT:
chatgpt
Equation rendering within LibreChat:
librechat

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions