MermaidJs
MermaidJs is a popular diagramming tool that allows you to create diagrams using a simple text syntax. The GenAIScript mermaid plugin provides a way to parse and render Mermaid diagrams within your GenAIScript applications.
The @genaiscript/plugin-mermaid package supports parsing mermaid diagrams. This can be useful to repair diagrams created by LLMs.
Installation
Section titled “Installation”npm i -D @genaiscript/plugin-mermaid
pnpm add -D @genaiscript/plugin-mermaid
yarn add -D @genaiscript/plugin-mermaid
If you are using the plugin in a Node.JS environment, without a .genai...
entry file, you will need
to initialize the runtime before using the plugin:
import { initialize } from "@genaiscript/runtime";
await initialize()
import { parse } from "@genaiscript/plugin-mermaid";
const res = await parse(` graph TD; A-->B; A-->C; B-->D; C-->D;`);
Why this plugin?
Section titled “Why this plugin?”The mermaid toolchain is meant to run in a browser environment, so it requires a bit of special work to make it work in Node.JS. Additionally, the mermaid package is quite large, so we decided to make it a plugin that you can install only if you need it.