Class ImageToDiagramProcess

java.lang.Object
dev.langchain4j.image_to_diagram.ImageToDiagramProcess
All Implemented Interfaces:
ImageToDiagram

public class ImageToDiagramProcess extends Object implements ImageToDiagram
Class for processing images to generate diagrams.
  • Constructor Details

    • ImageToDiagramProcess

      public ImageToDiagramProcess()
  • Method Details

    • workflow

      public StateGraph<ImageToDiagram.State> workflow() throws Exception
      Generates a workflow graph using the StateGraph framework with specific nodes and conditional edges.
      Returns:
      A configured StateGraph instance representing the workflow.
      Throws:
      Exception - if an error occurs during the configuration of the graph.
    • workflowWithCorrection

      public StateGraph<ImageToDiagram.State> workflowWithCorrection() throws Exception
      This method orchestrates a workflow for processing diagrams. It initializes a state graph and adds nodes and subgraphs to represent different stages of diagram correction and translation. The method also sets up conditional edges based on the type of diagram being translated.
      Returns:
      A StateGraph object representing the complete workflow diagram.
      Throws:
      Exception - if any errors occur during the setup of the workflow.
    • execute

      public org.bsc.async.AsyncGenerator<NodeOutput<ImageToDiagram.State>> execute(@NonNull @NonNull ImageToDiagramProcess.ImageUrlOrData imageData) throws Exception
      Executes the workflow using the provided image data and returns a stream of NodeOutput objects.
      Parameters:
      imageData - The image data to be processed, which must not be null.
      Returns:
      A stream of NodeOutput objects generated by the workflow.
      Throws:
      Exception - if an error occurs during execution.
    • executeWithCorrection

      public org.bsc.async.AsyncGenerator<NodeOutput<ImageToDiagram.State>> executeWithCorrection(@NonNull @NonNull ImageToDiagramProcess.ImageUrlOrData imageData) throws Exception
      Executes the workflow with correction for the given image data.
      Parameters:
      imageData - The image data to process, cannot be null.
      Returns:
      An asynchronous generator of node outputs.
      Throws:
      Exception - If an error occurs during execution.