Package org.bsc.langgraph4j.diagram
Class MermaidGenerator
java.lang.Object
org.bsc.langgraph4j.DiagramGenerator
org.bsc.langgraph4j.diagram.MermaidGenerator
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bsc.langgraph4j.DiagramGenerator
DiagramGenerator.Context
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Appends a footer to the content.protected void
Appends a header to the output based on the provided context.protected void
call
(DiagramGenerator.Context ctx, String from, String to) This method is an abstract method that must be implemented by subclasses.protected void
call
(DiagramGenerator.Context ctx, String from, String to, String description) Abstract method that must be implemented by subclasses to handle the logic of making a call.protected void
commentLine
(DiagramGenerator.Context ctx, boolean yesOrNo) Comment a line in the given context.protected void
declareConditionalEdge
(DiagramGenerator.Context ctx, int ordinal) Declares a conditional edge in the context with a specified ordinal.protected void
Declares a conditional element in the configuration or template.protected void
declareNode
(DiagramGenerator.Context ctx, String name) Declares a node in the specified context with the given name.Methods inherited from class org.bsc.langgraph4j.DiagramGenerator
generate, generate
-
Field Details
-
SUBGRAPH_PREFIX
public static final char SUBGRAPH_PREFIX- See Also:
-
-
Constructor Details
-
MermaidGenerator
public MermaidGenerator()
-
-
Method Details
-
appendHeader
Description copied from class:DiagramGenerator
Appends a header to the output based on the provided context.- Specified by:
appendHeader
in classDiagramGenerator
- Parameters:
ctx
- TheDiagramGenerator.Context
containing the information needed for appending the header.
-
declareConditionalStart
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 providedname
. It takes aContext
object that may contain additional parameters necessary for the declaration, and aname
which identifies the type or key associated with the conditional section.- Specified by:
declareConditionalStart
in classDiagramGenerator
- Parameters:
ctx
- The context containing contextual information needed for the declaration.name
- The name of the conditional section to be declared.
-
declareNode
Description copied from class:DiagramGenerator
Declares a node in the specified context with the given name.- Specified by:
declareNode
in classDiagramGenerator
- 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
Description copied from class:DiagramGenerator
Declares a conditional edge in the context with a specified ordinal.- Specified by:
declareConditionalEdge
in classDiagramGenerator
- Parameters:
ctx
- the contextordinal
- the ordinal value
-
commentLine
Description copied from class:DiagramGenerator
Comment a line in the given context.- Specified by:
commentLine
in classDiagramGenerator
- Parameters:
ctx
- The context in which the line is to be commented.yesOrNo
- Whether the line should be uncommented (true) or commented (false).
-
call
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 classDiagramGenerator
- 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
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 classDiagramGenerator
- 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.
-