Prompting the User for Acknowledgement or Information ===================================================== When running a workflow, it can be useful to show the user a short message or prompt the user for some information and wait for the user's response before the workflow proceeds. Starting with ``artificial-workflows==0.19.1``, the Artificial SDK supports this with :func:`~artificial.workflows.util.acknowledge` and :func:`~artificial.workflows.util.prompt`. Waiting for User for Acknowledgement ------------------------------------- Calling :func:`~artificial.workflows.util.acknowledge` will show a popup to the user with a message and a title. The workflow will wait for the user to acknowledge the message before proceeding. .. code-block:: python from artificial.workflows.decorators import workflow from artificial.workflows.util import acknowledge @workflow('Acknolwedge Workflow', 'acknowledge_wf', 'lab_eb85d8f8-9f23-47de-89e9-47a8af6b57d6') async def acknowledge_wf() -> None: await acknowledge('Message', 'Title') yields the following behavior: .. video:: _static/op-acknowledge.mp4 :autoplay: :muted: :loop: Prompting User for Information --------------------------------- Calling :func:`~artificial.workflows.util.prompt` will show a popup to the user with a form to fill out. The form is defined by a dataclass that you pass to the function. The function will wait for the user to fill out the form and click the submit button before proceeding. The function will return an instance of the dataclass with the values filled out by the user. The form fields will obey the dataclass :deco:`~artificial.workflows.decorators.field` annotations for adjusting labels, widgets, validation, etc. .. code-block:: python from dataclasses import dataclass from artificial.workflows.decorators import field, workflow from artificial.workflows.runtime import show_info from artificial.workflows.util import prompt @dataclass @field('int_field', {'uiTitle': 'Int Field'}) @field('str_field', {'uiTitle': 'String Field'}) class PromptType: int_field: int str_field: str @workflow('Prompt Workflow', 'prompt_wf', 'lab_eb85d8f8-9f23-47de-89e9-47a8af6b57d6') async def prompt_wf() -> None: prompt_vals: PromptType = await prompt(PromptType, 'Enter the following values:', 'Enter Values') await show_info(f'Int: {prompt_vals.int_field}, String: {prompt_vals.str_field}') yields the following behavior: .. video:: _static/op-prompt.mp4 :autoplay: :muted: :loop: