File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed
agentic/src/test/java/io/serverlessworkflow/fluent/agentic
func/src/main/java/io/serverlessworkflow/fluent/func Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -70,11 +70,13 @@ void chat_bot() {
70
70
t .listen (
71
71
"listenToMessages" ,
72
72
l ->
73
- l .one (c -> c .with (event -> event .type ("org.acme.chatbot.request" ))))
74
- .when (message -> !"" .equals (message .get ("message" )), Map .class )
73
+ l .until (message -> !"" .equals (message .get ("message" )), Map .class )
74
+ .one (
75
+ c ->
76
+ c .with (
77
+ event -> event .type ("org.acme.chatbot.request" ))))
75
78
.agent (chatBot )
76
- .emit (emit -> emit .event (e -> e .type ("org.acme.chatbot.reply" )))
77
- .then ("listenToMessages" ))
79
+ .emit (emit -> emit .event (e -> e .type ("org.acme.chatbot.reply" ))))
78
80
.build ();
79
81
80
82
try (WorkflowApplication app = WorkflowApplication .builder ().build ()) {
Original file line number Diff line number Diff line change 15
15
*/
16
16
package io .serverlessworkflow .fluent .func ;
17
17
18
+ import io .serverlessworkflow .api .types .AnyEventConsumptionStrategy ;
19
+ import io .serverlessworkflow .api .types .ListenTask ;
20
+ import io .serverlessworkflow .api .types .func .UntilPredicate ;
18
21
import io .serverlessworkflow .fluent .func .spi .ConditionalTaskBuilder ;
19
22
import io .serverlessworkflow .fluent .func .spi .FuncTransformations ;
20
23
import io .serverlessworkflow .fluent .spec .ListenTaskBuilder ;
24
+ import java .util .function .Predicate ;
21
25
22
26
public class FuncListenTaskBuilder extends ListenTaskBuilder
23
27
implements ConditionalTaskBuilder <FuncListenTaskBuilder >,
24
28
FuncTransformations <FuncListenTaskBuilder > {
25
29
30
+ private UntilPredicate untilPredicate ;
31
+
26
32
FuncListenTaskBuilder () {
27
33
super ();
28
34
}
35
+
36
+ public <T > FuncListenTaskBuilder until (Predicate <T > predicate , Class <T > predClass ) {
37
+ untilPredicate = new UntilPredicate ().withPredicate (predicate , predClass );
38
+ return this ;
39
+ }
40
+
41
+ @ Override
42
+ public ListenTask build () {
43
+ ListenTask task = super .build ();
44
+ AnyEventConsumptionStrategy anyEvent =
45
+ task .getListen ().getTo ().getAnyEventConsumptionStrategy ();
46
+ if (untilPredicate != null && anyEvent != null ) {
47
+ anyEvent .withUntil (untilPredicate );
48
+ }
49
+ return task ;
50
+ }
29
51
}
You can’t perform that action at this time.
0 commit comments