base_ui_worker
A worker whose job groups surface on the client UI.
Deprecated since version 1.12.0: Use UIWorker instead, which reports its
job groups to the client itself; dispatch from one of its @job
handlers where a BaseUIWorker was used as a dispatcher. Will be
removed in 2.0.0.
- class pipecat.workers.base_ui_worker.BaseUIWorker(**kwargs)[source]
Bases:
BaseWorkerWorker that surfaces its jobs and job groups on the client UI.
Deprecated since version 1.12.0: Use
UIWorkerinstead, which reports its job groups to the client itself. Will be removed in 2.0.0.Every group this worker dispatches is registered for lifecycle forwarding: a
group_startedenvelope is published at dispatch, worker updates and responses are forwarded asjob_update/job_completedenvelopes,group_completedis published at group teardown (normal completion, cancellation, or timeout), and the client’s reserved__cancel_job_groupevent is translated intocancel_job_groupfor groups dispatched as cancellable.Instantiable directly (no LLM): register one on the runner as a dispatcher when a pipeline app wants client-visible background work:
ui_jobs = BaseUIWorker("ui-jobs") job_id = await ui_jobs.request_job_group( "wikipedia", "news", params=JobGroupParams( payload={"query": query}, label=f"Research: {query}", ), )
- async create_job_group_and_request_job(worker_names: list[str], **kwargs) JobGroup[source]
Dispatch a job group and announce it to the client.
- Parameters:
worker_names – Names of the workers to send the job to.
**kwargs – Everything
create_job_group_and_request_job()takes, forwarded unchanged.
- Returns:
The created
JobGroup.
- async cancel_job_group(job_id: str, *, reason: str | None = None) None[source]
Cancel a running job group and complete its client card.
- Parameters:
job_id – The job identifier to cancel.
reason – Optional human-readable reason for cancellation.
- async on_bus_message(message: BusMessage) None[source]
Handle the client’s reserved
__cancel_job_groupevent.Everything else this worker forwards to the client hangs off the job hooks (
on_job_update(),on_job_response(),on_job_stream_end(),on_job_completed()), which the base class calls at the right point in a group’s lifecycle.- Parameters:
message – The
BusMessageto process.
- async on_job_update(message: BusJobUpdateMessage | BusJobUpdateUrgentMessage) None[source]
Forward a worker’s progress update to the client.
- async on_job_response(message: BusJobResponseMessage | BusJobResponseUrgentMessage) None[source]
Forward a worker’s response to the client as its terminal envelope.
Runs before the group is torn down, so on an error status (with
cancel_on_error) the client learns which worker failed before the card closes.
- async on_job_stream_end(message: BusJobStreamEndMessage) None[source]
Forward a worker’s stream end as its terminal envelope.
A worker may finish by ending its stream instead of responding; the client is told it completed, with the final stream data as the response payload.
- async on_job_completed(result: JobGroupResponse) None[source]
Complete the client’s card for a group whose workers all finished.