Skip to content
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

Add ability to visualize the workflow using mermaid #290

Closed
maximilien opened this issue Mar 6, 2025 · 3 comments · Fixed by #296
Closed

Add ability to visualize the workflow using mermaid #290

maximilien opened this issue Mar 6, 2025 · 3 comments · Fixed by #296
Assignees
Labels
documentation Improvements or additions to documentation feature New feature

Comments

@maximilien
Copy link
Member

maximilien commented Mar 6, 2025

Add a method to Workflow::to_mermaid() -> str

Mermaid is flexible so not only graphs can be represented but also sequence diagram:

sequenceDiagram
    participant agent1
    participant agent2
    participant agent3
    
    agent1->>agent2: step1
    agent2->>agent3: step2
    agent2-->>agent1: step3
    agent1->>agent3: step4
Loading

And flowcharts with:

  flowchart TD;
      agent1 -- condition1 -->agent2;
      agent2-->agent3;
Loading

And graphs with:

  graph TD;
      agent1-->agent2;
      agent2-->agent3;
Loading

Find details about Mermaid here and JavaScript libraries.

@maximilien maximilien added documentation Improvements or additions to documentation feature New feature labels Mar 6, 2025
@maximilien
Copy link
Member Author

You can then include the markdown in your HTML pages with something like:

<!DOCTYPE html>
<html>
<head>
    <title>Mermaid Diagram Example</title>
</head>
<body>
    <h1>Flowchart</h1>
    <div class="mermaid">
        graph LR
            A[Start] --> B{Decision}
            B -- Yes --> C[Process 1]
            B -- No --> D[Process 2]
            C --> E[End]
            D --> E
    </div>

    <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
    <script>
      mermaid.initialize({ startOnLoad: true });
    </script>
</body>
</html>

@maximilien
Copy link
Member Author

@psschwei this could be a good one to help on if @akihikokuroda has not started. Should be easy to get basics and we can improve later. Let us know.

@maximilien
Copy link
Member Author

maximilien commented Mar 10, 2025

OK folks, I will take this one @akihikokuroda and @psschwei

Pushing initial PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature New feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants