Skip to content

Commit d357bf0

Browse files
committed
updated sequence demo
Signed-off-by: Dmitrii Tikhomirov <[email protected]>
1 parent 9cab274 commit d357bf0

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

experimental/fluent/agentic/src/test/java/io/serverlessworkflow/fluent/agentic/LC4JEquivalenceIT.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static io.serverlessworkflow.fluent.agentic.dsl.AgenticDSL.conditional;
2020
import static io.serverlessworkflow.fluent.agentic.dsl.AgenticDSL.doTasks;
2121
import static io.serverlessworkflow.fluent.agentic.dsl.AgenticDSL.loop;
22+
import static io.serverlessworkflow.fluent.agentic.dsl.AgenticDSL.tryCatch;
2223
import static io.serverlessworkflow.fluent.spec.dsl.DSL.tasks;
2324
import static org.assertj.core.api.Assertions.assertThat;
2425
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -49,7 +50,7 @@ public void sequentialWorkflow() {
4950

5051
Workflow wf =
5152
workflow("seqFlow")
52-
.tasks(tasks -> tasks.sequence("process", creativeWriter, audienceEditor, styleEditor))
53+
.sequence("process", creativeWriter, audienceEditor, styleEditor)
5354
.build();
5455

5556
List<TaskItem> items = wf.getDo();
@@ -120,8 +121,9 @@ public void loopWorkflowWithMaxIterations() {
120121

121122
Predicate<AgenticScope> until = s -> s.readState("score", 0).doubleValue() >= 0.8;
122123

123-
Workflow wf =
124-
AgentWorkflowBuilder.workflow("retryFlow").tasks(loop(until, scorer, 5, editor)).build();
124+
tryCatch(loop(until, scorer, 5, editor));
125+
126+
Workflow wf = workflow("retryFlow").loop(until, scorer, 5, editor).build();
125127

126128
List<TaskItem> items = wf.getDo();
127129
assertThat(items).hasSize(1);
@@ -186,9 +188,7 @@ public void errorHandling() {
186188
var styleEditor = AgentsUtils.newStyleEditor();
187189

188190
Workflow wf =
189-
workflow("seqFlow")
190-
.tasks(tasks -> tasks.sequence("process", creativeWriter, audienceEditor, styleEditor))
191-
.build();
191+
workflow("seqFlow").sequence("process", creativeWriter, audienceEditor, styleEditor).build();
192192

193193
List<TaskItem> items = wf.getDo();
194194
assertThat(items).hasSize(3);

experimental/fluent/agentic/src/test/java/io/serverlessworkflow/fluent/agentic/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ String story = (String) novelCreator.invoke(input);
8080
### Serverless Workflow
8181

8282
```java
83-
Workflow wf = workflow("seqFlow").tasks(tasks -> tasks.sequence("process", creativeWriter, audienceEditor, styleEditor)).build();
83+
Workflow wf = workflow("seqFlow").sequence("process", creativeWriter, audienceEditor, styleEditor).build();
8484

8585
try (WorkflowApplication app = WorkflowApplication.builder().build()) {
8686
String result = app.workflowDefinition(wf).instance(input).start().get().asText().orElseThrow();
@@ -151,10 +151,8 @@ String story = styledWriter.writeStoryWithStyle("dragons and wizards", "comedy")
151151
```java
152152
Predicate<AgenticScope> until = s -> s.readState("score", 0).doubleValue() >= 0.8;
153153

154-
Workflow wf =
155-
AgentWorkflowBuilder.workflow("retryFlow")
156-
.tasks(loop(until, scorer, 5, editor))
157-
.build();
154+
Workflow wf = workflow("retryFlow").loop(until, scorer, 5, editor).build();
155+
158156

159157
Map<String, Object> input =
160158
Map.of(

0 commit comments

Comments
 (0)