Event handler
Defines an abstract base class for all event handlers used throughout the Gen AI applications.
References
NONE
BaseEventHandler(name=None)
Bases: ABC
An abstract base class for all event handlers used throughout the Gen AI applications.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name assigned to the event handler. |
Initializes a new instance of the BaseEventHandler class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name assigned to the event handler. Defaults to the class name. |
None
|
close()
async
Closes the event handler.
By default, this method does nothing. Subclasses can override this method to perform cleanup tasks (e.g., closing connections or releasing resources) when needed. Event handlers that do not require cleanup can inherit this default behavior without any changes.
Returns:
Type | Description |
---|---|
None
|
None |
emit(event)
abstractmethod
async
Emits the given event.
This abstract method must be implemented by subclasses to define how an event is emitted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event |
Event
|
The event to be emitted. |
required |
Raises:
Type | Description |
---|---|
NotImplementedError
|
If the method is not implemented in a subclass. |