Skip to content

Commit fd74d80

Browse files
authored
add helper conditional to the AgenticDSL class (#811)
* add helper conditional to the AgenticDSL class Signed-off-by: Dmitrii Tikhomirov <[email protected]> * added conditionalSequence and conditionalParallel Signed-off-by: Dmitrii Tikhomirov <[email protected]> * better naming Signed-off-by: Dmitrii Tikhomirov <[email protected]> --------- Signed-off-by: Dmitrii Tikhomirov <[email protected]>
1 parent de20a41 commit fd74d80

File tree

1 file changed

+12
-0
lines changed
  • experimental/fluent/agentic/src/main/java/io/serverlessworkflow/fluent/agentic/dsl

1 file changed

+12
-0
lines changed

experimental/fluent/agentic/src/main/java/io/serverlessworkflow/fluent/agentic/dsl/AgenticDSL.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ public static AgentTaskConfigurer sequence(Object... agents) {
113113
return list -> list.sequence(agents);
114114
}
115115

116+
public static AgentTaskConfigurer sequence(Predicate<?> predicate, Object... agents) {
117+
return list -> list.sequence(agents).when(predicate);
118+
}
119+
116120
public static AgentTaskConfigurer loop(Predicate<AgenticScope> exitCondition, Object... agents) {
117121
return list -> list.loop(l -> l.subAgents(agents).exitCondition(exitCondition));
118122
}
@@ -121,6 +125,10 @@ public static AgentTaskConfigurer parallel(Object... agents) {
121125
return list -> list.parallel(agents);
122126
}
123127

128+
public static AgentTaskConfigurer parallel(Predicate<?> predicate, Object... agents) {
129+
return list -> list.parallel(agents).when(predicate);
130+
}
131+
124132
// --------- Tasks ------ //
125133
public static Consumer<AgentDoTaskBuilder> doTasks(AgentTaskConfigurer... steps) {
126134
Objects.requireNonNull(steps, "Steps in a tasks are required");
@@ -140,6 +148,10 @@ public static AgentTaskConfigurer agent(Object agent) {
140148
return list -> list.agent(agent);
141149
}
142150

151+
public static AgentTaskConfigurer conditional(Predicate<?> predicate, Object agent) {
152+
return list -> list.agent(agent).when(predicate);
153+
}
154+
143155
public static AgentTaskConfigurer emit(Consumer<FuncEmitTaskBuilder> event) {
144156
return list -> list.emit(event);
145157
}

0 commit comments

Comments
 (0)