subscriber

Bus subscriber mixin for receiving messages from an WorkerBus.

class pipecat.bus.subscriber.BusSubscriber[source]

Bases: object

Mixin for objects that receive messages from an WorkerBus.

Implementors override on_bus_message() to handle incoming messages. Concrete subscribers must provide a name property (typically inherited from BaseObject).

property name: str

Unique name identifying this subscriber on the bus.

accepts_bus_message(message: BusMessage) → bool[source]

Whether this subscriber should be handed this message.

Checked by the bus before every delivery. Returning False drops the message for this subscriber alone; others still receive it. Subscribers that take everything, which is the default, need not override this.

Parameters:

message – The bus message about to be delivered.

Returns:

Whether to deliver the message.

async on_bus_message(message: BusMessage) → None[source]

Handle an incoming bus message.

Only called for messages accepts_bus_message() allowed.

Parameters:

message – The bus message to handle.