|
| 1 | +# Human In The Loop |
| 2 | + |
| 3 | +Guide for **Human-In-The-Loop** scenarios within the UiPath-LLamaIndex integration. |
| 4 | +It focuses on the **ctx.write_event_to_stream** LlamaIndex functionality. |
| 5 | + |
| 6 | +## Models Overview |
| 7 | + |
| 8 | +### 1. CreateAction |
| 9 | + |
| 10 | +The `CreateAction` model is utilized to create an escalation action within the UiPath Action Center as part of an interrupt context. The action will rely on a previously created UiPath app. |
| 11 | +After addressing the escalation, the current agent will resume execution. |
| 12 | +For more information on UiPath apps, refer to the [UiPath Apps User Guide](https://docs.uipath.com/apps/automation-cloud/latest/user-guide/introduction). |
| 13 | + |
| 14 | +#### Attributes: |
| 15 | + |
| 16 | +- **name** (Optional[str]): The name of the app. |
| 17 | +- **key** (Optional[str]): The key of the app. |
| 18 | +- **title** (str): The title of the action to create. |
| 19 | +- **data** (Optional[Dict[str, Any]]): Values that the action will be populated with. |
| 20 | +- **app_version** (Optional[int]): The version of the app (defaults to 1). |
| 21 | +- **assignee** (Optional[str]): The username or email of the person assigned to handle the escalation. |
| 22 | + |
| 23 | +#### Example: |
| 24 | + |
| 25 | +```python |
| 26 | +from uipath.models import CreateAction |
| 27 | +action_output = ctx.write_event_to_stream(CreateAction(name="AppName", title="Escalate Issue", data={"key": "value"}, app_version=1, assignee="user@example.com")) |
| 28 | +``` |
| 29 | + |
| 30 | +For a practical implementation of the `CreateAction` model, refer to the [action-center-hitl-agent](https://github.com/UiPath/uipath-llamaindex-python/tree/main/samples/action-center-hitl-agent). This sample demonstrates how to create an action with dynamic input. |
| 31 | + |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +### 2. WaitAction |
| 36 | + |
| 37 | +The `WaitAction` model is used to wait for an action to be handled. This model is intended for scenarios where the action has already been created. |
| 38 | + |
| 39 | +#### Attributes: |
| 40 | + |
| 41 | +- **action** (Action): The instance of the action to wait for. |
| 42 | + |
| 43 | +#### Example: |
| 44 | + |
| 45 | +```python |
| 46 | +from uipath.models import WaitAction |
| 47 | +action_output = ctx.write_event_to_stream(WaitAction(action=my_action_instance)) |
| 48 | +``` |
| 49 | + |
| 50 | +--- |
| 51 | + |
| 52 | +> 💡 UiPath LlamaIndex sdk also supports **Robot/Agent-in-the-loop** scenarios. In this context, the execution of one agent |
| 53 | +> can be suspended until another robot or agent finishes its execution. |
| 54 | +
|
| 55 | +### 3. InvokeProcess |
| 56 | + |
| 57 | +The `InvokeProcess` model is utilized to invoke a process within the UiPath cloud platform. |
| 58 | +This process can be of various types, including API workflows, Agents or RPA automation. |
| 59 | +Upon completion of the invoked process, the current agent will automatically resume execution. |
| 60 | + |
| 61 | +#### Attributes: |
| 62 | + |
| 63 | +- **name** (str): The name of the process to invoke. |
| 64 | +- **input_arguments** (Optional[Dict[str, Any]]): A dictionary containing the input arguments required for the invoked process. |
| 65 | + |
| 66 | +#### Example: |
| 67 | + |
| 68 | +```python |
| 69 | +from uipath.models import InvokeProcess |
| 70 | +process_output = ctx.write_event_to_stream(InvokeProcess(name="MyProcess", input_arguments={"arg1": "value1"})) |
| 71 | +``` |
| 72 | + |
| 73 | +For a practical implementation of the `InvokeProcess` model, refer to the [multi-agent sample](https://github.com/UiPath/uipath-llamaindex-python/tree/main/samples/multi-agent). This sample demonstrates how to invoke a process with dynamic input arguments, showcasing the integration of the interrupt functionality within a multi-agent system or a system where an agent integrates with RPA processes and API workflows. |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +### 4. WaitJob |
| 78 | + |
| 79 | +The `WaitJob` model is used to wait for a job completion. Unlike `InvokeProcess`, which automatically creates a job, this model is intended for scenarios where |
| 80 | +the job has already been created. |
| 81 | + |
| 82 | +#### Attributes: |
| 83 | + |
| 84 | +- **job** (Job): The instance of the job that the agent will wait for. This should be a valid job object that has been previously created. |
| 85 | + |
| 86 | +#### Example: |
| 87 | + |
| 88 | +```python |
| 89 | +from uipath.models import WaitJob |
| 90 | +job_output = ctx.write_event_to_stream(WaitJob(job=my_job_instance)) |
| 91 | +``` |
0 commit comments