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: JobGroupContext

Job group whose lifecycle is forwarded to the UI client.

Behaves like JobGroupContext for the dispatching code, and additionally forwards the group’s lifecycle – start, per-worker progress, and completion – to the UI client as ui-job-group envelopes, so the client can show a cancellable progress card. Workers need not know about the UI surface: any send_job_update they emit against the group’s job_id is 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 UIWorker that owns this job group.

  • worker_names – Names of the workers to send the job to.

  • name – Optional job name for routing to named @job handlers 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_group event. Defaults to True.

property label: str | None

The group’s human-readable label.

Returns:

The label surfaced to the client, or None if unset.

property cancellable: bool

Whether the client may request cancellation.

Returns:

True if the client may cancel this group via the reserved __cancel_job_group event.