If there is markdown content returned from OpenAI which is not successfully parsed by
markdown-it
, you are welcome to share that in the OpenAI community forum.
Thank you for your response, but I’m afraid that currently, using only markdown-it cannot adequately visualize special information such as mathematics. Even with all the extensions of markdown-it, the mathematical formulas returned by the ChatGPT API are not in a standard format.
The following program was running fine earlier this year.
import MarkdownIt from "markdown-it";
import mdKatex from "@vscode/markdown-it-katex";
import mdKbd from "markdown-it-kbd";
import mdHighlight from "markdown-it-highlightjs";
function onMarkdown(content: any){
const markdown = MarkdownIt();
markdown.use(mdKatex);
markdown.use(mdKbd);
markdown.use(mdHighlight);
markdown.use(codePlugin);
markdown.use(imagePlugin);
return markdown.render(content, {});
}
I must include the following prompt in all conversations for the ChatGPT API to return markdown-it parseable format correctly.
When dealing with mathematical formulas, please use $...$ to enclose the formula, not [...].
Here’s an incorrect example of a conversation.
Sure! Here's a step-by-step guide using LaTeX to construct a matrix and solve for eigenvalues and eigenvectors:
1. Construct the matrix:
Let's create a 2x2 matrix as an example:
\[ A = \begin{pmatrix} 2 & 1 \\ 1 & 3 \end{pmatrix} \]
2. Find the characteristic equation:
The characteristic equation is given by:
\[ \text{det}(A - \lambda I) = 0 \]
Substitute A into the equation:
\[ \text{det}\left( \begin{pmatrix} 2 & 1 \\ 1 & 3 \end{pmatrix} - \lambda \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} \right) = 0 \]
3. Solve for eigenvalues:
Expand the determinant and solve for λ:
\[ \text{det}\left( \begin{pmatrix} 2-\lambda & 1 \\ 1 & 3-\lambda \end{pmatrix} \right) = 0 \]
\[ (2-\lambda)(3-\lambda) - 1 = 0 \]
\[ \lambda^2 - 5\lambda + 5 = 0 \]
\[ \lambda = \frac{5 \pm \sqrt{5}}{2} \]
4. Solve for eigenvectors:
Substitute the eigenvalues back into (A - λI)x = 0 and solve for x. For each eigenvalue, you will get a corresponding eigenvector.
I hope this helps you in constructing a matrix and solving for eigenvalues and eigenvectors using LaTeX! Let me know if you need further assistance.
The above markdown content cannot be correctly parsed in standard markdown-it. I raised this issue in the community a while ago, and they suggested I ask here. Many adults in the community have raised this issue, and currently, most solutions used are rather rough and temporary.
If you don’t think it’s necessary to optimize this area, at the very least, ensure that the format of API responses is correct and standard. It should at least be compatible with mainstream open-source components because these are commonly used by developers. After all, the API is paid for, and developers are investing money. As official maintainers of the OpenAI repository, you should strive to better maintain this repository for the benefit of developers.