You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A workflow is a sequence of steps that the agent must execute one by one. Each step execution then requires a user validation before the agent can proceed to the next step.
5
-
Compared to the tasks, the workflows are more complex and constrainted, allowing the user to keep more control over the agent's actions.
4
+
A workflow is a sequence of steps that the agent must execute one by one. A step is code: anything can be done in this code including complex actions as API calls.
5
+
6
+
The result of each step execution is always available to the user that can consult it. On the steps requiring user validation, user can edit the step result and sometimes open a chat to give an instruction to relaunch the step.
7
+
Compared to the instruct tasks, the workflows are more complex and constrainted, allowing the user to keep more control over the agent's actions.
6
8
7
9
## How to create a new workflow?
8
10
9
-
STEP 1: Create the steps' code
10
-
In `backend>app>models>workflows` create a new folder named by your workflow. In this folder, create one file per step in your workflow.
11
-
In each of those files, implement the crresponding step code.
11
+
### STEP 1: Create the steps' code
12
+
In `mojodex_core>workflows` create a new folder named by your workflow. In this folder, create one file per step in your workflow.
13
+
In each of those files, implement the corresponding step code.
12
14
A workflow step is a class that implements the `WorkflowStep` class.
13
15
14
-
An implementation of `WorkflowStep` looks like this:
16
+
An implementation of `WorkflowStep` overrides the method `_execute()`. It looks like this:
In `backend>app>models>workflows>steps_library.py`, add your steps to the `STEPS` dictionary. The key must be the name of the step and the value must be the class of the step. This is used to dynamically load the steps from their name in the database.
31
+
The result of the step execution must be a list of dictionaries. The next step of the workflow will be executed as many time as there are dictionaries in the list, each time with the corresponding dictionary as parameter.
43
32
44
-
STEP 3: Create the workflow
45
-
To create a new workflow, you can use the dedicated route PUT `/workflow`
33
+
### STEP 2: Add your steps to the steps library
34
+
In `mojodex_core>workflows>steps_library.py`, add your steps to the `STEPS` dictionary. The key must be the name of the step as later defined in DB and the value must be the class of the step. This is used to dynamically load the steps from their name in the database.
35
+
36
+
### STEP 3: Create the workflow
37
+
To create a new workflow, you can use the dedicated route PUT `/task`.
46
38
47
39
Replace `<BACKOFFICE_SECRET>` with your actual token and name, steps, icon and description with the actual workflow name, steps, icon and description.
48
40
> Careful: steps names must match the ones in the steps library.
49
-
> Careful: steps must be in the right order.
50
41
51
42
Then, run the following command in your terminal:
52
43
53
44
```shell
54
-
curl --location --request PUT 'http://localhost:5001/workflow' \
45
+
curl --location --request PUT 'http://localhost:5001/task' \
"result_chat_enabled": false # Whether the chat is enabled at the end of the workflow on the produced text or not.
86
88
}'
87
89
```
88
90
89
-
STEP 4: Define workflow checkpoints
90
-
By default, every step is defined as a checkpoint. This means that at the end of each step_execution_run, if the user does not validate the result, the user will give an instruction and this same step_execution_run will be executed again.
91
-
92
-
Example on Qualify Lead workflow:
93
-
Step 1 is "Write the query you will use with SERP API to search Google"
94
-
95
-
- Step 1 - Run 1 - Execution 1:
96
-
parameter: {"company": "Hoomano"}
97
-
learned instructions: None
98
-
step result: "query: 'Hoomano industry'"
99
-
<USERDOESNOTVALIDATE>
100
-
user instruction: "This query is not specific enough, please add more keywords"
101
-
102
-
- Step 1 - Run 1 - Execution 2:
103
-
parameter: {"company": "Hoomano"}
104
-
learned instructions: "Make specific queries"
105
-
step result: "query: 'Hoomano company industry trends AI"
106
-
<USERVALIDATES>
107
-
108
-
On the contrary, if a step is not defined as a checkpoint, the user will give an instruction but the last checkpoint step last run will be executed again.
109
-
Let's keep Qualify Lead workflow example running:
110
-
Step 2 is "Check the SERP API results and select the 3 most relevant one"
111
-
112
-
- Step 2 - Run 1 - Execution 1:
113
-
parameter: {"query": "Hoomano company industry trends AI"}
114
-
learned instructions: None
115
-
step result: "result 1, result 2, ..."
116
-
<USERDOESNOTVALIDATE>
117
-
user instruction: "This is not relevant, please try again, look for any blog post the company wrote"
118
-
119
-
- Step 1 - Run 1 - Execution 3:
120
-
parameter: {"company": "Hoomano"}
121
-
learned instructions: "Make specific queries, look for any blog post the company wrote"
122
-
step result: "query: 'Hoomano company AI blog posts"
123
-
<USERVALIDATES>
124
-
125
-
- Step 2 - Run 2 - Execution 1:
126
-
parameter: {"query": "Hoomano company AI blog posts"}
127
-
learned instructions: "Make specific queries, look for any blog post the company wrote"
128
-
step result: "result 1, result 2, ..."
129
-
<USERVALIDATES>
130
-
131
-
STEP 5: Associate workflow to a user through a product.
132
-
Replace `<BACKOFFICE_SECRET>` with your actual token and `<user_id>` and `<workflow_pk>` with the actual user id and workflow primary key.
> - Assistant will no longer be able to re-launch past steps code - therefore relaunch api requests or other…
94
+
> - Text has been generated by a whole chain of steps. It could be too long for context-windows on a basic LLM chat call.
95
+
96
+
> As a consequence, depending on the workflow, it may be relevant to disable the chat on result to avoid user confusion (preventing them to ask to re-launch a query for example)
97
+
98
+
99
+
### STEP 4: Associate workflow to a user through a product.
100
+
Replace `<BACKOFFICE_SECRET>` with your actual token and `<user_id>` and `<task_pk>` with the actual user id and workflow primary key.
133
101
Then, run the following command in your terminal:
134
102
135
103
136
104
Default user `demo@example.com` is associated with default product `demo` with pk 1. Let's add the task to this product.
137
105
```
138
-
curl --location --request PUT 'http://localhost:5001/product_workflow_association' \
106
+
curl --location --request PUT 'http://localhost:5001/product_task_association' \
0 commit comments