interaction¶
The Interaction module provides mechanisms for handling human-machine interactions in Automa.
This module contains several important interface definitions for implementing event handling, feedback collection, and interaction control during Automa execution.
There are two fundamental mechanisms for human-machine interactions in Automa:
- Feedback Request Mechanism: For simple interaction scenarios during Automa execution.
- Human Interaction Mechanism: For long-running interaction scenarios that require interruption and resumption during Automa execution.
EventHandlerType module-attribute ¶
EventHandlerType: TypeAlias = Union[
Callable[[Event, FeedbackSender], None],
Callable[[Event], None],
]
The type of the event handler. It can be a function that takes an Event and a FeedbackSender as arguments, or a function that takes only an Event as an argument.
Event ¶
Bases: BaseModel
An event is a message that is sent from one worker inside the Automa to the application layer outside the Automa.
Source code in bridgic/core/automa/interaction/_event_handling.py
event_type class-attribute instance-attribute ¶
The type of the event. The type of the event is used to identify the event handler registered to handle the event.
timestamp class-attribute instance-attribute ¶
The timestamp of the event.
data class-attribute instance-attribute ¶
The data attached to the event.
Feedback ¶
Bases: BaseModel
A feedback is a message that is sent from the application layer outside the Automa to a worker inside the Automa.
Source code in bridgic/core/automa/interaction/_event_handling.py
FeedbackSender ¶
Bases: ABC
The appliction layer must use FeedbackSender to send back feedback to the worker inside the Automa.
Source code in bridgic/core/automa/interaction/_event_handling.py
send ¶
abstractmethod send(feedback: Feedback) -> None
Send feedback to the Automa. This method can be called only once for each event.
This send method can be safely called in several different scenarios: - In the same asyncio Task of the same event loop as the event handler. - In a different asyncio Task of the same event loop as the event handler. - In a different thread from the event handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feedback | Feedback | The feedback to be sent. | required |
Source code in bridgic/core/automa/interaction/_event_handling.py
InteractionFeedback ¶
Bases: Feedback
A feedback object that contains both the data provided by the user and the interaction_id, which uniquely identifies the corresponding interaction.
Source code in bridgic/core/automa/interaction/_human_interaction.py
InteractionException ¶
Bases: Exception
An exception raised when the interact_with_human method is called one or more times within the latest event loop iteration, causing one or multiple human interactions to be triggered.
Source code in bridgic/core/automa/interaction/_human_interaction.py
interactions property ¶
interactions: List[Interaction]
A list of Interaction objects that occurred during the latest event loop iteration.
Multiple Interaction objects may be generated because, within the latest event loop iteration, multiple workers calling the interact_with_human method might be running concurrently in parallel branches of the graph.
Interaction ¶
Bases: BaseModel
An object that represents a single interaction between the Automa and a human. Each call to interact_with_human will generate an Interaction object which will be included in the InteractionException raised.