Skip to content

Commit

Permalink
feat: update flows examples
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Dvorak <toomas2d@gmail.com>
  • Loading branch information
Tomas2D committed Dec 19, 2024
1 parent d955f7d commit a0a303f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions examples/flows/simple.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import { Flow } from "bee-agent-framework/flows";
import { Flow } from "bee-agent-framework/experimental/flows";
import { z } from "zod";

const schema = z.object({
hops: z.number().default(0),
});

const flow = new Flow({ schema })
.addStep("a", async (state) => ({})) // does nothing
.addStep("b", async (state) => ({
// adds one and moves to b
.addStep("a", async (state) => ({
update: { hops: state.hops + 1 },
}))
.addStep("c", async (state) => ({
update: { hops: state.hops + 1 },
next: Math.random() > 0.5 ? "b" : Flow.END,
.addStep("b", () => ({
next: Math.random() > 0.5 ? Flow.PREV : Flow.END,
}));

const response = await flow.run({ hops: 0 }).observe((emitter) => {
Expand Down

0 comments on commit a0a303f

Please sign in to comment.