cogk / reacteur

Automation and computation toolbox for no-code development for Frappe / Dodock.
GNU General Public License v3.0
3 stars 0 forks source link

feat: Continuations #3

Open cogk opened 7 months ago

cogk commented 7 months ago

Examples:

flowchart TB

subgraph flow1 [Subflow 1]
direction TB
Z1[Entrypoint]
-->A1(["A1. prompt (What is your name?)"])
-->|text| B1[\B1. Suspension/]
end

flow1 -.->|"Continuation data:<br>{'text': text, 'continuation_token': 'subflow-2'}"| flow2

subgraph flow2 [Subflow 2]
direction TB
Z2[Entrypoint]
-->A2[/A2. Continuation\]
-->|text| B2(["B2. send_email (Hello {{ text }})"])
--> C2...
end
cogk commented 7 months ago

Storing data across execution contexts

cogk commented 7 months ago

How to store documents in Continuation Data?

It's not possible:

  1. because of the serialization constraints;
  2. because it does not make sense in an asynchronous context: the document might disappear or change before Continuation;

How to transfer complex data across execution contexts?

Let's say I have an interactive flow that mimics an authentication. It asks for the user's name and password, then the user's OTP code.

flowchart TB
subgraph main
    a[Entrypoint]
==>|init| b[Ask interactive: Username?]
-.->|ok\nasync| c[Ask interactive: Password?]
-.->|ok\nasync| z[Check user exists]
==>|ok| d[Ask interactive: OTP Code?]
-.->|ok\nasync| y[Check OTP]
==>|ok| e["Show result: Welcome {{ username }}!"]
end

subgraph context
%%subgraph coda1
bx([username]) --o b
%%subgraph coda2
cx([password]) --o c
%%subgraph coda3
dx([otp_code]) --o d
%%end
%%end
%%end
end

bx ~~~ cx ~~~ dx

bx --- z
cx --- z
bx --- y
dx --- y