gitdiagram icon indicating copy to clipboard operation
gitdiagram copied to clipboard

Syntax error in text mermaid version 11.4.1

Open chenyang-shanghai opened this issue 9 months ago • 64 comments

In the step 3/3, "Syntax error in text mermaid version 11.4.1" occurs frequently. Maybe we should state In the prompt that the LLM is required to strictly adhere to the Mermaid syntax.

chenyang-shanghai avatar Feb 17 '25 03:02 chenyang-shanghai

Same here with repo coding in Python (fastapi)

rachidje avatar Feb 18 '25 15:02 rachidje

Same here

Chrys4lis01 avatar Feb 19 '25 12:02 Chrys4lis01

Same here with one of my repos

pr0pz avatar Feb 21 '25 12:02 pr0pz

Run into same problem here

stanoswald avatar Feb 22 '25 16:02 stanoswald

Same here with any repo

danielsole avatar Feb 25 '25 10:02 danielsole

Same problem

RealmiRoblox avatar Feb 28 '25 09:02 RealmiRoblox

This error simply means the LLM generated incorrect Mermaid.js diagram code.

I've tried addressing this issue in numerous ways but ultimately I find that there is no reliable way. It is mostly a limitation of the LLM. If there is a way to validate Mermaid.js code, that would help but as of now I am not sure how.

Maybe we should state In the prompt that the LLM is required to strictly adhere to the Mermaid syntax.

I already do this, for the errors that I've specifically found. You can see it in the prompts.py under the third prompt (that generates the Mermaid.js code), but of course this is not guaranteed and new errors always show up.

ahmedkhaleel2004 avatar Feb 28 '25 13:02 ahmedkhaleel2004

This error simply means the LLM generated incorrect Mermaid.js diagram code.

I've tried addressing this issue in numerous ways but ultimately I find that there is no reliable way. It is mostly a limitation of the LLM. If there is a way to validate Mermaid.js code, that would help but as of now I am not sure how.

Maybe we should state In the prompt that the LLM is required to strictly adhere to the Mermaid syntax.

I already do this, for the errors that I've specifically found. You can see it in the prompts.py under the third prompt (that generates the Mermaid.js code), but of course this is not guaranteed and new errors always show up.

Thanks for the reply. I've used this before, but it was a few months ago and it worked fine. I fully understand why it might take time (or may never get fixed) but thank you!

Voidless7125 avatar Feb 28 '25 13:02 Voidless7125

That's an LLM issue; most LLMs still can't generate an error-free Mermaid Diagram.

I suggest, as a fallback, that you return to the user the Incorrect Code, The user could tune it or give it back to another LLM to tune and fix it. That will be beneficial

@ahmedkhaleel2004

gitnasr avatar Feb 28 '25 23:02 gitnasr

That's an LLM issue; most LLMs still can't generate an error-free Mermaid Diagram.

I suggest, as a fallback, that you return to the user the Incorrect Code, The user could tune it or give it back to another LLM to tune and fix it. That will be beneficial

@ahmedkhaleel2004

Opened #34, @ahmedkhaleel2004. Can you please check it out?

gitnasr avatar Mar 17 '25 22:03 gitnasr

Is there a way for the mermaid.js code to be ran through a separate bash process where code valdiation is determined by the exit code and the llm can self-correct based on the error stack? (W/out having taken a look at the current repo structure, Im assuming that this is a possibility)

h8ngryDev4Hire avatar Mar 19 '25 18:03 h8ngryDev4Hire

Hey may I know what LLM you r using? Mistral AI codestral one generates error free mermaids most of the time. I used the same model in one of my app code to flow charts. And it's dam cheap aswell

nithinworks avatar Mar 28 '25 04:03 nithinworks

what LLM you r using

openai o3-mini

ahmedkhaleel2004 avatar Mar 28 '25 04:03 ahmedkhaleel2004

what LLM you r using

openai o3-mini

It might be worth giving Gemini a shot with mermaid documentation in cache. The large context window usually solves these issues.

jonathanbertholet avatar Mar 28 '25 09:03 jonathanbertholet

I tried with two of my repos written in Python. It worked when I stayed on the tab without switching, but when I tried it and I changed the tab during the diagram creation it failed

Tenvid avatar Mar 28 '25 14:03 Tenvid

Also here

Image

hizmarck avatar Mar 29 '25 00:03 hizmarck

Same

Image

rootulp avatar Mar 29 '25 01:03 rootulp

I tried to get as much info as I could on this issue by looking at the doc and testing on my side (https://mermaid.js.org/intro/syntax-reference.html)

  • small repository seems to be ok
  • medium repo has trouble if files are long, it get lost easily
  • large repo has 100% chance of not displaying

no matter the custom instruction, we can't influence the 3rd step before the rendering... the custom instruction only seems to affect the 1st step

Toastaspiring avatar Mar 29 '25 01:03 Toastaspiring

@ahmedkhaleel2004 , i was also facing this issue

18121A05L2 avatar Mar 29 '25 06:03 18121A05L2

Same here!

bdfsaraiva avatar Mar 29 '25 08:03 bdfsaraiva

Same Issue. Do we have a solution yet?

Draudnaut avatar Mar 30 '25 15:03 Draudnaut

Same issues for my repos

msurguy avatar Mar 30 '25 18:03 msurguy

same :)

iambumblehead avatar Mar 30 '25 18:03 iambumblehead

Adding a custom instruction like "Fix syntax error" fixes the mermaid errors for me

puravparab avatar Mar 31 '25 02:03 puravparab

+1

This repository : https://github.com/HeroTransitions/Hero

In step 3 also throw this Exception

HookDing avatar Mar 31 '25 07:03 HookDing

Same,https://gitdiagram.com/JanisZhang/PR-conflicts-alert

JanisZhang avatar Mar 31 '25 07:03 JanisZhang

+1

mbelveder avatar Mar 31 '25 09:03 mbelveder

+1

cr2007 avatar Apr 01 '25 07:04 cr2007

Same for https://github.com/immobiliare/backstage-plugin-gitlab

Image

GloomyDay avatar Apr 01 '25 14:04 GloomyDay

Tried at least 3 repos( Python/Golang, even PHP ), non of them works .

GloomyDay avatar Apr 01 '25 14:04 GloomyDay