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.CallStyle, DiagramGenerator.Context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAppends a footer to the content.protected voidAppends a header to the output based on the provided context.protected voidcall(DiagramGenerator.Context ctx, String from, String to, String description, DiagramGenerator.CallStyle style) Abstract method that must be implemented by subclasses to handle the logic of making a call.protected voidcall(DiagramGenerator.Context ctx, String from, String to, DiagramGenerator.CallStyle style) This method is an abstract method that must be implemented by subclasses.protected voidcommentLine(DiagramGenerator.Context ctx, boolean yesOrNo) Comment a line in the given context.protected voiddeclareConditionalEdge(DiagramGenerator.Context ctx, int ordinal) Declares a conditional edge in the context with a specified ordinal.protected voidDeclares a conditional element in the configuration or template.protected voiddeclareNode(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, isEnd, isStart
-
Constructor Details
-
MermaidGenerator
public MermaidGenerator()
-
-
Method Details
-
appendHeader
Description copied from class:DiagramGeneratorAppends a header to the output based on the provided context.- Specified by:
appendHeaderin classDiagramGenerator- Parameters:
ctx- TheDiagramGenerator.Contextcontaining the information needed for appending the header.
-
declareConditionalStart
Description copied from class:DiagramGeneratorDeclares 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 aContextobject that may contain additional parameters necessary for the declaration, and anamewhich identifies the type or key associated with the conditional section.- Specified by:
declareConditionalStartin 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:DiagramGeneratorDeclares a node in the specified context with the given name.- Specified by:
declareNodein 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:DiagramGeneratorDeclares a conditional edge in the context with a specified ordinal.- Specified by:
declareConditionalEdgein classDiagramGenerator- Parameters:
ctx- the contextordinal- the ordinal value
-
commentLine
Description copied from class:DiagramGeneratorComment a line in the given context.- Specified by:
commentLinein 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
protected void call(DiagramGenerator.Context ctx, String from, String to, DiagramGenerator.CallStyle style) Description copied from class:DiagramGeneratorThis 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:
callin 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
protected void call(DiagramGenerator.Context ctx, String from, String to, String description, DiagramGenerator.CallStyle style) Description copied from class:DiagramGeneratorAbstract method that must be implemented by subclasses to handle the logic of making a call.- Specified by:
callin 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.
-