Step 4: Call an Assistant#

Assistants are dynamic digital guides describing the Actions people need to take as a part of an overall orchestrated workflow. In Orchestration Python, an Assistant is integrated into your workflows by calling it like any other Action. The dynamic in “dynamic digital guide” arrives via the ability to pass parameters to the Assistant and have the Assistant update content such as quantities or referenced equipment dynamically OR show and hide content dynamically.

Hello Assistant#

In order to call an Assistant, it of course, must first exist. Create an Assistant similar to the one pictured below, using this article as a guide Creating an Assistant.

_images/assistant_builder.png

Once your Assistant is created, switch to your Codespace and open the Artificial Workflow Authoring extension. If the assistant is not displayed in the Assistant pane, click refresh. It should display as red, flagging the lack of generated code to support calling the Assistant in the workflow.

_images/extension_error.png

Click “Generate Assistant Stubs” to generate the assistant function. This will generate an assistants_stubs.py in the /workflow folder, which can be imported and used directly in your workflow.

Note the name of the import will vary based on the Lab name, and the details of the Assistant may vary based on the details of the Assistant created. To get a matching function signature, drag and drop from the Assistant pane in the extension into the Workflow code.

_images/dnd_assistant.gif
from artificial.workflows.decorators import workflow, parameter
from artificial.workflows.runtime import show_info
from stubs.stubs_assistants import HelloLabAssistants


@parameter('hello_message', {'required': True, 'uiTitle': 'Hello Message'})
@workflow('Hello Workflow', 'hello_workflow', 'lab_c9eae09e-ceed-46d1-8390-87ff7dd8586d')
async def hello_workflow(hello_message: str) -> None:

    await HelloLabAssistants.hello_assistant(
        name='From The Adapter',
    )

    await show_info(hello_message)

Publish the workflow edits using the Artificial extension.

_images/publish.gif

Run the Workflow to see the Assistant banner display and run the Assistant to see the values passed through.

_images/metrics.png _images/assistant.png