langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
49.47k stars 7.08k forks source link

ParseError: KaTex parse error: Expected 'EOF', got '#' at position 2 #9666

Open majestichou opened 3 days ago

majestichou commented 3 days ago

Self Checks

Dify version

0.9.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

1 A workflow is created. The big model replies with the following content:

对于无人机:\n$$\\chi_{n,m}\\sim N\\left( \\mu_{RCS},\\sigma_{RCS}^{2} \\right)$$\n\n对于车辆:\n$$PL_{Vehicle} = PL1 + PL2 + 10\\log_{10}\\left( \\frac{\\lambda^{2}}{4\\pi} \\right) –  –  –  –   –   –   –    –     ——                          ————                         ————                       ————          ————      ————      ————\n\n### 提案\n- **提案1**:为了全面通用性,每个散射点的大尺度中的第 The above content is from the log of the dify debugging the workflow.

  1. The following figure shows the content displayed on the dify web page. image

  2. According to the output effect, the fonts are displayed in red. In addition, the output format of the subsequent text is abnormal. image

  3. I put my mouse over the red text and I can see an error:ParseError: KaTex parse error: Expected 'EOF', got '#' at position 2

  4. Then I created a simple workflow that could repeat my prompt words, and I entered the prompt words in the dialog box that triggered the bug described above. image

It can be found that the same problem arises.

✔️ Expected Behavior

The text color and output format of the web page are displayed properly.

❌ Actual Behavior

ParseError: KaTex parse error: Expected 'EOF', got '#' at position 2 The fonts are displayed in red. In addition, the output format of the subsequent text is abnormal.

dosubot[bot] commented 3 days ago

The error message "ParseError: KaTex parse error: Expected 'EOF', got '#' at position 2" suggests that there is an issue with the KaTeX parsing of your mathematical expressions. This error typically occurs when there is unexpected syntax in the LaTeX code being processed by KaTeX.

Here are a few steps you can take to troubleshoot and resolve this issue:

  1. Check for Syntax Errors: Review the LaTeX expressions in your workflow for any syntax errors. Ensure that all LaTeX commands are correctly formatted and that there are no extraneous characters, such as the # symbol, which might be causing the parse error.

  2. Simplify Expressions: Try simplifying the LaTeX expressions to isolate the part that is causing the error. Start with a basic expression and gradually add complexity to identify the problematic section.

  3. Validate LaTeX Code: Use an online LaTeX editor or validator to check if the expressions render correctly outside of Dify. This can help confirm whether the issue is with the LaTeX code itself or with how it's being processed in Dify.

  4. Escape Special Characters: If your expressions include special characters (like #), ensure they are properly escaped or used within the correct context in LaTeX.

  5. Review Documentation: Check the Dify documentation or any available resources for specific guidelines on using LaTeX within the platform, as there might be platform-specific considerations.

By following these steps, you should be able to identify and correct the source of the parsing error. If the issue persists, consider providing a minimal reproducible example to further investigate the problem.

To continue talking to Dosu, mention @dosu.

majestichou commented 2 days ago

In addition, the above tests used Qwen2.5-72B-Instruct of vllm deployment. And the parameters are as follows: image