fastapi_transport

The eval transport over a WebSocket the bot accepted itself.

On Pipecat Cloud a session’s WebSocket arrives already accepted, and the hops in between pass on only the session body, never the URL’s query. The harness therefore sends its connection’s flags as its first message, eval-connect, which create_transport reads before building this transport with them. The flags are those EvalTransport reads from its URL, applied the same way: skip_tts before on_client_connected, so a greeting made there is silent too.

The connection is the session, so on_client_disconnected fires whenever the harness disconnects, letting the bot end with it.

class pipecat.evals.fastapi_transport.EvalFastAPIWebsocketInputTransport(transport: BaseTransport, client: FastAPIWebsocketClient, params: FastAPIWebsocketParams, **kwargs)[source]

Bases: FastAPIWebsocketInputTransport

Input transport that serves the harness’s image.

A vision bot asks for the user’s camera image; under eval there is no camera, so the image the harness registered for the turn is served instead. With no image registered, the request is answered with an error, so the function call that made it still finishes.

async process_frame(frame: Frame, direction: FrameDirection)[source]

Serve image requests; otherwise behave like the base input transport.

class pipecat.evals.fastapi_transport.EvalFastAPIWebsocketOutputTransport(transport: BaseTransport, client: FastAPIWebsocketClient, params: FastAPIWebsocketParams, **kwargs)[source]

Bases: FastAPIWebsocketOutputTransport

Output transport that reports the bot’s images to the harness.

An image the bot outputs is handed to the serializer as it arrives, whether or not the bot enabled video output; the serializer sends it only when the harness asked.

async process_frame(frame: Frame, direction: FrameDirection)[source]

Report output images; otherwise behave like the base output transport.

class pipecat.evals.fastapi_transport.EvalFastAPIWebsocketTransport(websocket: fastapi.WebSocket, params: EvalTransportParams, flags: EvalConnectionFlags, input_name: str | None = None, output_name: str | None = None)[source]

Bases: FastAPIWebsocketTransport

The eval transport over an accepted FastAPI WebSocket (see the module docstring).

Event handlers available:

  • on_client_connected(transport, websocket): The harness connected

  • on_client_disconnected(transport, websocket): The harness disconnected

  • on_session_timeout(transport, websocket): Session timed out

__init__(websocket: fastapi.WebSocket, params: EvalTransportParams, flags: EvalConnectionFlags, input_name: str | None = None, output_name: str | None = None)[source]

Initialize the transport.

Parameters:
  • websocket – The accepted WebSocket, its eval-connect message already read.

  • params – The bot’s eval transport parameters.

  • flags – The connection’s flags, from its eval-connect message.

  • input_name – Optional name for the input processor.

  • output_name – Optional name for the output processor.