-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPIKE: Get Mermaid charts rendering #1063
base: main
Are you sure you want to change the base?
Conversation
CSP_REPORT_TO = "csp-endpoint" | ||
CSP_FONT_SRC = ( | ||
"'self'", | ||
"s3.amazonaws.com", | ||
) | ||
CSP_STYLE_SRC = ("'self'",) | ||
CSP_STYLE_SRC = ("'self'", "'unsafe-inline'") # TO DO: Not happy about this change - look at workarounds (KE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude suggests some solutions:
- Server side rendering with
py-mermaid
- Host mermaid on a subdomain
- Use web workers
- Use the (unfortunately-named) CSP nonces to allow specific inline scripts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Will! I'm going to try a JavaScript workaround in the first instance, as that will be the quickest solution (if it works!).
I think the SSR approach is also a strong contender. A little more fiddly because of the streaming, but I can see a couple of ways of approaching that.
Any thoughts/concerns around the system prompts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add something to the effect of "if asked to create a diagram use the mermaid markdown format". I find that pretty much every LLM is quite fluent in it
A nice elegant change. As you note in an above thread, server side rendering is going to be prickly with the streaming which makes me think this is a client side thing for now. My main thought is that LLM's can screw up in the validity of their mermaid definition which could cause errors. We might want to wrap that in our current "Redbox had an error" styling. Finally, a copy and paste/download button specifically for the diagram would be really useful for people to grab and use these in documents and presentations |
6b8abf2
to
2cc974e
Compare
2cc974e
to
babbcb7
Compare
If/when we come back to this, now we have Lit SSR running this will likely give us good options. |
Context
Getting diagrams rendering in chat, using Mermaid:
Still to explore
Error: <circle> attribute cy: Expected length, "NaN"
Things to check