Class MermaidGenerator

java.lang.Object
org.bsc.langgraph4j.DiagramGenerator
org.bsc.langgraph4j.diagram.MermaidGenerator

public class MermaidGenerator extends DiagramGenerator
This class represents a MermaidGenerator that extends DiagramGenerator. It generates a flowchart using Mermaid syntax. The flowchart includes various nodes such as start, stop, web_search, retrieve, grade_documents, generate, transform_query, and different conditional states.
  • Field Details

  • Constructor Details

    • MermaidGenerator

      public MermaidGenerator()
  • Method Details

    • appendHeader

      protected void appendHeader(DiagramGenerator.Context ctx)
      Description copied from class: DiagramGenerator
      Appends a header to the output based on the provided context.
      Specified by:
      appendHeader in class DiagramGenerator
      Parameters:
      ctx - The DiagramGenerator.Context containing the information needed for appending the header.
    • appendFooter

      protected void appendFooter(DiagramGenerator.Context ctx)
      Description copied from class: DiagramGenerator
      Appends a footer to the content.
      Specified by:
      appendFooter in class DiagramGenerator
      Parameters:
      ctx - Context object containing the necessary information.
    • declareConditionalStart

      protected void declareConditionalStart(DiagramGenerator.Context ctx, String name)
      Description copied from class: DiagramGenerator
      Declares a conditional element in the configuration or template. This method is used to mark the start of a conditional section based on the provided name. It takes a Context object that may contain additional parameters necessary for the declaration, and a name which identifies the type or key associated with the conditional section.
      Specified by:
      declareConditionalStart in class DiagramGenerator
      Parameters:
      ctx - The context containing contextual information needed for the declaration.
      name - The name of the conditional section to be declared.
    • declareNode

      protected void declareNode(DiagramGenerator.Context ctx, String name)
      Description copied from class: DiagramGenerator
      Declares a node in the specified context with the given name.
      Specified by:
      declareNode in class DiagramGenerator
      Parameters:
      ctx - the context in which to declare the node @literal (not null)
      name - the name of the node to be declared @literal (not null, not empty)
    • declareConditionalEdge

      protected void declareConditionalEdge(DiagramGenerator.Context ctx, int ordinal)
      Description copied from class: DiagramGenerator
      Declares a conditional edge in the context with a specified ordinal.
      Specified by:
      declareConditionalEdge in class DiagramGenerator
      Parameters:
      ctx - the context
      ordinal - the ordinal value
    • commentLine

      protected void commentLine(DiagramGenerator.Context ctx, boolean yesOrNo)
      Description copied from class: DiagramGenerator
      Comment a line in the given context.
      Specified by:
      commentLine in class DiagramGenerator
      Parameters:
      ctx - The context in which the line is to be commented.
      yesOrNo - Whether the line should be uncommented (true) or commented (false).
    • call

      protected void call(DiagramGenerator.Context ctx, String from, String to)
      Description copied from class: DiagramGenerator
      This method is an abstract method that must be implemented by subclasses. It is used to initiate a communication call between two parties identified by their phone numbers.
      Specified by:
      call in class DiagramGenerator
      Parameters:
      ctx - The current context in which the call is being made.
      from - The phone number of the caller.
      to - The phone number of the recipient.
    • call

      protected void call(DiagramGenerator.Context ctx, String from, String to, String description)
      Description copied from class: DiagramGenerator
      Abstract method that must be implemented by subclasses to handle the logic of making a call.
      Specified by:
      call in class DiagramGenerator
      Parameters:
      ctx - The context in which the call is being made.
      from - The phone number of the caller.
      to - The phone number of the recipient.
      description - A brief description of the call.