In this example, refer to the effect of diify's chatFlow to simulate the implementation of video content:
- /video/7455114080131482152/
Solon Flow is a general-purpose flow orchestration engine. Orchestration scenarios that can be used for calculation (or tasks); can be used for business rules and decision-making processing orchestration scenarios; can be used for office approval (stateful, interruptible, personnel participation) orchestration scenarios; can be used for long-term processes (combined with automatic progress, waiting for intervention). Also supports: java8, java11, java17, java21, java24.
<dependency>
<groupId></groupId>
<artifactId>solon-flow</artifactId>
<version>Latest version</version>
</dependency>
The main features are:
- Use yaml format for orchestration
- Expressions and scripts free
- Meta-information configuration provides unlimited space for expansion (each process is equivalent to bringing its own metadatabase)
- Event broadcast and callback support
- Supports two requirements classifications: "stateless" and "stateful"
- Driver customization (like JDBC, MySql, PostgreSQL, and maybe Elasticsearch)
The following are two choreography styles for reference
1. Use "Meta-Information" + Task Component" style (more conducive to visual interface configuration)
id: demo1
layout:
- title: "Start"
type: start
- title: "File Extraction"
: "file" # The configuration of the visual interface (represented by meta information)
: "fileTxt"
task: @FileLoaderCom
- title: "LLM"
: "Qwen/Qwen2.5-72B-Instruct" # Configuration of the visual interface (represented by meta information)
: "fileTxt"
:
- role: system
content: "#role\nYou are a data expert, formatting and conversion of deleted data\n\n#context\n${fileTxt}\n\n#task\nExtract strings in csv format"
task: @ChatModelCom
- title: "Parameter Extractor"
: "Qwen/Qwen2.5-72B-Instruct" # Configuration of the visual interface (represented by meta information)
: "csvData"
task: @ParamExtractionCom
- title: "Execute code"
: "csvData"
task: |
import ;
String json = (().get("")); //Convert to json data
String echatCode = (json); //Convert to echat chart code
= echatCode; //Return as result
- title: "End"
type: end
This style is more suitable for the compilation of visual interfaces. Design is that many components can be pre-selected and designed, and after management and configuration, interface selection can be provided.
@Component("FileLoaderCom")
public class FileLoaderCom implements TaskComponent {
@Override
public void run(FlowContext context, Node node) throws Throwable {
...
}
}
@Component("ChatModelCom")
public class ChatModelCom implements TaskComponent {
@Override
public void run(FlowContext context, Node node) throws Throwable {
...
}
}
@Component("ParamExtractionCom")
public class ParamExtractionCom implements TaskComponent {
@Override
public void run(FlowContext context, Node node) throws Throwable {
...
}
}
@Controller
public class DemoController {
@Mapping("demo")
public Object input(UploadedFile attachment, String message) throws Throwable {
FlowEngine flowEngine = ();
("classpath:flow/");
FlowContext ctx = new FlowContext();
("file", attachment);
("demo1");
return ;
}
}
2. A more primitive style (can express the general process of inner thought):
id: demo1
layout:
- title: "Start"
type: start
- title: "File Extraction"
: "file" # The configuration of the visual interface (represented by meta information)
: "fileTxt"
task: |
import .*;
var loader = (file);
var fileTxt = ();
(().get(""), fileTxt); //Push in context (successive nodes are available)
- title: "LLM"
: "Qwen/Qwen2.5-72B-Instruct" # Configuration of the visual interface (represented by meta information)
: "fileTxt"
:
- role: system
content: "#role\nYou are a data expert, formatting and conversion of deleted data\n\n#context\n${fileTxt}\n\n#task\nExtract strings in csv format"
task: |
import ; //According to business packaging, you can quickly obtain the configured model
import ; //According to business packaging, messages can be quickly built
var chatModel = (().get("model"));
var chatMessages = (().get("messages"), context);
var resp = (chatMessages).call();
("resp", resp);
- title: "Parameter Extractor"
: "Qwen/Qwen2.5-72B-Instruct" # Configuration of the visual interface (represented by meta information)
: "csvData"
task: |
(().get(""), ().getContent());
- title: "Execute code"
: "csvData"
task: |
import ;
String json = (().get("")); //Convert to json data
String echatCode = (json); //Convert to echat chart code
= echatCode; //Return as result
- title: "End"
type: end
This style is relatively primitive, but does not require java components to participate. You can run configuration files directly like low code (or executable programs).
@Controller
public class DemoController {
@Mapping("demo")
public Object input(UploadedFile attachment, String message) throws Throwable {
FlowEngine flowEngine = ();
("classpath:flow/");
FlowContext ctx = new FlowContext();
("file", attachment);
("demo1");
return ;
}
}