ui_job_context
User-facing job group context.
Wraps JobGroupContext so the work it dispatches is also surfaced
to the UI client through the UI Worker protocol. Apps reach this via
UIWorker.ui_job_group(...) rather than constructing it directly.
- class pipecat.workers.ui.ui_job_context.UIJobGroupContext(worker: UIWorker, worker_names: tuple[str, ...], *, name: str | None = None, payload: dict | None = None, timeout: float | None = None, cancel_on_error: bool = True, label: str | None = None, cancellable: bool = True)[source]
Bases:
JobGroupContextJob group whose lifecycle is forwarded to the UI client.
Behaves like
JobGroupContextfor the dispatching code, and additionally forwards the group’s lifecycle – start, per-worker progress, and completion – to the UI client asui-job-groupenvelopes, so the client can show a cancellable progress card. Workers need not know about the UI surface: anysend_job_updatethey emit against the group’sjob_idis forwarded automatically.Example:
async with self.ui_job_group( "researcher_a", "researcher_b", payload={"query": query}, label=f"Research: {query}", cancellable=True, ) as tg: async for event in tg: ... results = tg.responses
- __init__(worker: UIWorker, worker_names: tuple[str, ...], *, name: str | None = None, payload: dict | None = None, timeout: float | None = None, cancel_on_error: bool = True, label: str | None = None, cancellable: bool = True)[source]
Initialize the UIJobGroupContext.
- Parameters:
worker – The parent
UIWorkerthat owns this job group.worker_names – Names of the workers to send the job to.
name – Optional job name for routing to named
@jobhandlers on the workers.payload – Optional structured data describing the work.
timeout – Optional timeout in seconds covering both the ready-wait and job execution.
cancel_on_error – Whether to cancel the group if a worker errors. Defaults to True.
label – Optional human-readable label surfaced to the client (e.g.
"Research: Radiohead"). The client UI uses it to title the in-flight job-group card.cancellable – Whether the client may request cancellation of this group via the reserved
__cancel_job_groupevent. Defaults to True.
- property label: str | None
The group’s human-readable label.
- Returns:
The label surfaced to the client, or
Noneif unset.
- property cancellable: bool
Whether the client may request cancellation.
- Returns:
Trueif the client may cancel this group via the reserved__cancel_job_groupevent.