NextChat
NextChat copied to clipboard
[Bug] LaTeX Syntax still bug
Describe the bug this symbol "\frac{1}{2}$." and this one "$a$, $b$, and $c$"
Logs chat : Einstein's mass-energy equivalence equation.md
this one aswell
- $$2x^2 - 5x + 2 = 0$$
- $2x^2 - 5x + 2 = 0$ are $x = 2$ and $x = \frac{1}{2}$.
I found that it worked fine after add a space after the left "$"
I found that it worked fine after add a space after the left "$"
need changed in this https://github.com/Yidadaa/ChatGPT-Next-Web/blob/f2485931d9b3680234f4816f4526759c8d4b741e/app/components/markdown.tsx#L102
function escapeDollarNumber(text: string) {
let escapedText = "";
for (let i = 0; i < text.length; i += 1) {
let char = text[i];
const nextChar = text[i + 1] || " ";
if (char === "$" && nextChar >= "0" && nextChar <= "9") {
char = "\\$";
}
escapedText += char;
}
return escapedText;
}
it fixed by adding space bar in char = "\ \$";
before is char = "\\$";
It makes sense, I think the author add this function to avoid some sentense being misunderstood, like
I got $2 for a hotdog and $1 for a cup of tea.
But it also bring another issue here
It makes sense, I think the author add this function to avoid some sentense being misunderstood, like
I got $2 for a hotdog and $1 for a cup of tea.
But it also bring another issue here
yeah you right if adding space bar in char = "\ \$";
before is char = "\\$";
it bring another issue
about I got $2 for a hotdog and $1 for a cup of tea.
I believe we can simply remove the function here, as in my opinion, there are numerous cases where numbers are followed by a dollar sign in mathematical expressions, which would cause a lot of confusion. Additionally, the alternative scenario is probably rare.
Furthermore, adding a method to determine whether the dollar sign here represents currency or a mathematical expression is likely to be very costly.
I believe we can simply remove the function here, as in my opinion, there are numerous cases where numbers are followed by a dollar sign in mathematical expressions, which would cause a lot of confusion. Additionally, the alternative scenario is probably rare.
Furthermore, adding a method to determine whether the dollar sign here represents currency or a mathematical expression is likely to be very costly.
must made another function only for math I guess for fix a lot of confusion
I believe we can simply remove the function here, as in my opinion, there are numerous cases where numbers are followed by a dollar sign in mathematical expressions, which would cause a lot of confusion. Additionally, the alternative scenario is probably rare. Furthermore, adding a method to determine whether the dollar sign here represents currency or a mathematical expression is likely to be very costly.
must made another function only for math I guess for fix a lot of confusion
The main issue is that we seem unable to automatically differentiate whether the text returned by GPT is a LaTeX expression or a currency symbol.
I'm wondering if we can address this problem through prompt engineering by asking GPT to actively add escape characters for these currency symbol, for example:
The price of pineapple fried rice is \$5
, which is \$1
cheaper than before.
I believe we can simply remove the function here, as in my opinion, there are numerous cases where numbers are followed by a dollar sign in mathematical expressions, which would cause a lot of confusion. Additionally, the alternative scenario is probably rare. Furthermore, adding a method to determine whether the dollar sign here represents currency or a mathematical expression is likely to be very costly.
must made another function only for math I guess for fix a lot of confusion
The main issue is that we seem unable to automatically differentiate whether the text returned by GPT is a LaTeX expression or a currency symbol.
I'm wondering if we can address this problem through prompt engineering by asking GPT to actively add escape characters for these currency symbol, for example:
The price of pineapple fried rice is
\$5
, which is\$1
cheaper than before.
the text returned by GPT is $3x^2 + 6x - 9 = 0$
mostly (e.g when you entering "$$ 3x^2 + 6x - 9 = 0 $$")
logs :
Quadratic Equation: Solving for x
Message From ChatGPT:
You are an assistant that Quadratic Equation: Solving for x
Message From You:
$$ 3x^2 + 6x - 9 = 0 $$
Message From ChatGPT:
To solve the quadratic equation $3x^2 + 6x - 9 = 0$, we can use the quadratic formula. The quadratic formula states that for an equation in the form $ax^2 + bx + c = 0$, the solutions for $x$ can be found using the formula:
$$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$
In our equation, $a = 3$, $b = 6$, and $c = -9$. Substituting these values into the quadratic formula, we get:
$$x = \frac{-6 \pm \sqrt{6^2 - 4(3)(-9)}}{2(3)}$$
Simplifying further:
$$x = \frac{-6 \pm \sqrt{36 + 108}}{6}$$ $$x = \frac{-6 \pm \sqrt{144}}{6}$$ $$x = \frac{-6 \pm 12}{6}$$
This gives us two possible solutions for $x$:
$$x_1 = \frac{-6 + 12}{6} = \frac{6}{6} = 1$$ $$x_2 = \frac{-6 - 12}{6} = \frac{-18}{6} = -3$$
Therefore, the solutions to the equation $3x^2 + 6x - 9 = 0$ are $x = 1$ and $x = -3$.
also we can't tell gpt to show output format in prompt because it's weird, its better depends what gpt said
so the main problem its only that how we can escaping $$
without conflict of single $
for Math/Latex
another issue :
this a $
"$3 \times 10^8$" should be "$ 3 \times 10^8$"
if "$ 3 \times 10^8$"
it will show output correctly
$ 3 \times 10^8$
info update
looks better
using this code :
// used to be for math / latex
function escapeDollarNumber(text: string) {
let escapedText = "";
for (let i = 0; i < text.length; i += 1) {
let char = text[i];
const nextChar = text[i + 1] || " ";
if (char === "$" && nextChar >= "\\" + "0" + "\\" && nextChar <= "\\" + "9" + "\\") {
char = "\\$";
}
escapedText += char;
}
return escapedText;
}
// used to be $ any still wip
function escapeDollarMathNumber(text: string) {
let escapedText = "";
let isInMathExpression = false;
for (let i = 0; i < text.length; i += 1) {
let char = text[i];
const nextChar = text[i + 1] || " ";
if (char === "$") {
isInMathExpression = !isInMathExpression;
}
if (char === "$" && nextChar >= "0" && nextChar <= "9" && !isInMathExpression) {
char = " " + nextChar;
}
escapedText += char;
}
return escapedText;
}
function _MarkDownContent(props: { content: string }) {
const escapedContent = useMemo(() => {
let processedContent = props.content;
if (processedContent.includes("$")) {
processedContent = escapeDollarMathNumber(processedContent);
}
processedContent = escapeDollarNumber(processedContent);
return processedContent;
}, [props.content]);
output json :
only single dollar now a issue
@VergilWang15 issue should be fixed for sure (I am smart)
testing on azure by asking "can you solving this $3x^2 + 6x - 9 = 0$ ?"
output json :
code :
// used to be for math / latex
function escapeDollarNumber(text: string) {
let escapedText = "";
for (let i = 0; i < text.length; i += 1) {
let char = text[i];
const nextChar = text[i + 1] || " ";
if (char === "$" && nextChar >= "\\" + "0" + "\\" && nextChar <= "\\" + "9" + "\\") {
char = "\\$";
}
escapedText += char;
}
return escapedText;
}
// used to be $ any
function escapeDollarMathNumber(text: string) {
let escapedText = "";
let isInMathExpression = false;
for (let i = 0; i < text.length; i += 1) {
let char = text[i];
const nextChar = text[i + 1] || " ";
if (char === "$") {
isInMathExpression = !isInMathExpression;
}
if (char === "$" && nextChar >= "0" && nextChar <= "9" && !isInMathExpression) {
char = "$" + nextChar; // "$" <--- this magic
i += 1; // Skip the next character since we have already included it
}
escapedText += char;
}
return escapedText;
}
function _MarkDownContent(props: { content: string }) {
const escapedContent = useMemo(() => {
let processedContent = props.content;
if (processedContent.includes("$")) {
processedContent = escapeDollarMathNumber(processedContent);
}
processedContent = escapeDollarNumber(processedContent);
return processedContent;
}, [props.content]);
Another Highlight:
- Azure
- OpenAI
another highligh gpt-4-1106-preview
:
@VergilWang15 it won't conflict now
BetaTesting : https://github.com/H0llyW00dzZ/ChatGPT-Next-Web/commit/236f9fc2e7ca33400b55389ffa9a5c0d67d561aa
Models : gpt-4-1106-preview
looks nice!
looks nice!
list model recommended & not recommended for LaTex Syntax https://github.com/Yidadaa/ChatGPT-Next-Web/discussions/3351
I also have the same problem, not even with the latest version 2.10.1 the issue has been resolved.
By the way, can NextChat modify the listening address and port?
By the way, can NextChat modify the listening address and port?
you mean ip address and port ?
you mean ip address and port ?
yes
you mean ip address and port ?
yes
Currently, it doesn't support ip address and port. You need to forward it to a domain such as localhost
or use a service like https://ngrok.com/.
Can this feature be supported? Basically, when I deploy in pod, I can directly use the localhost:3000 reverse proxy for NextWeb, but one-api also uses port number 3000, which causes conflicts, and it is indeed strange that the listening address and port cannot be modified.
Can this feature be supported? Basically, when I deploy in pod, I can directly use the localhost:3000 reverse proxy for NextWeb, but one-api also uses port number 3000, which causes conflicts, and it is indeed strange that the listening address and port cannot be modified.
You can change the port by rebuilding the application, for instance, in Docker.
this one you need to changed it
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/main/Dockerfile#L43C1-L44C1
this one you need to changed it
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/main/Dockerfile#L43C1-L44C1
This appears to be just docker's port mapping.
this one you need to changed it https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/main/Dockerfile#L43C1-L44C1
This appears to be just docker's port mapping.
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/main/docker-compose.yml
or use docker desktop it much easier to fix conflict ports example:
Bot detected the issue body's language is not English, translate it automatically.
or use docker desktop it much easier to fix conflict ports example: