Class TranslateSequenceDiagramToPlantUML
java.lang.Object
dev.langchain4j.image_to_diagram.actions.TranslateSequenceDiagramToPlantUML
- All Implemented Interfaces:
NodeAction<ImageToDiagram.State>
public class TranslateSequenceDiagramToPlantUML
extends Object
implements NodeAction<ImageToDiagram.State>
The `TranslateSequenceDiagramToPlantUML` class implements the NodeAction<ImageToDiagram.State> interface.
It is responsible for translating a sequence diagram into PlantUML code using an OpenAI chat model.
-
Constructor Summary
ConstructorDescriptionTranslateSequenceDiagramToPlantUML
(dev.langchain4j.model.openai.OpenAiChatModel model) Constructor for `TranslateSequenceDiagramToPlantUML`. -
Method Summary
Modifier and TypeMethodDescriptionapply
(ImageToDiagram.State state) Converts a sequence diagram from an image to PlantUML code.
-
Constructor Details
-
TranslateSequenceDiagramToPlantUML
public TranslateSequenceDiagramToPlantUML(dev.langchain4j.model.openai.OpenAiChatModel model) Constructor for `TranslateSequenceDiagramToPlantUML`.- Parameters:
model
- the OpenAiChatModel to use for translation
-
-
Method Details
-
apply
Converts a sequence diagram from an image to PlantUML code. This method processes the given state containing an image, generates a system prompt, and uses a language model to produce PlantUML code representing the diagram. If no diagram is provided in the state, it throws an IllegalArgumentException.- Specified by:
apply
in interfaceNodeAction<ImageToDiagram.State>
- Parameters:
state
- The input state containing an image for conversion.- Returns:
- A map with a key "diagramCode" containing the generated PlantUML code.
- Throws:
Exception
- if there is an error during the conversion process.
-