serializer
Frame serializer that bridges the eval harness to a bot over RTVI.
The eval harness (pipecat.evals.harness) talks to a bot using the RTVI
protocol over a plain WebSocket (SingleClientWebsocketServerTransport). This serializer
is the only glue needed:
Inbound (harness → bot): JSON RTVI messages are wrapped in an
InputTransportMessageFrameso the bot’sRTVIProcessorparses and routes them (send-text,raw-audio,dtmf,client-ready, …). Two control messages are the exception: aclient-messagewitht = "eval-context"is short-circuited into anLLMMessagesUpdateFrame(reseeding the bot’s context), and one witht = "eval-configure"into anRTVIConfigureObserverFrame(raising the function-call report level for the eval). Both keep eval-specific behavior out of the bot, and the latter is the trust boundary that lets bots keep the secure default report level in production.Outbound (bot → harness): RTVI server messages (carried as
OutputTransportMessage*Framewith thertvi-ailabel) are emitted as their raw JSON. Everything else — notably bot audio — is dropped, since the harness only asserts on semantic events.
This lives under pipecat.evals rather than pipecat.serializers because
it carries eval-specific behavior (the context short-circuit, dropping audio) and
is not a general-purpose RTVI transport serializer.
- class pipecat.evals.serializer.RTVIEvalSerializer(**kwargs)[source]
Bases:
FrameSerializerBridges JSON RTVI messages and pipeline frames for the eval harness.
Use as the serializer of a
SingleClientWebsocketServerTransportwhen running a bot under the eval harness. The bot pipeline must include anRTVIProcessorand pass anRTVIObserverto the task.- __init__(**kwargs)[source]
Initialize the serializer.
- Parameters:
**kwargs – Additional arguments passed to
FrameSerializer.
- set_capture_audio(capture: bool) None[source]
Enable/disable forwarding the bot’s synthesized audio to the harness.
- get_user_image() tuple[bytes, str] | None[source]
The image registered for the current turn as
(bytes, mime), or None.
- async serialize(frame: Frame) str | bytes | None[source]
Serialize an outbound frame to JSON for the harness.
Only RTVI server messages are forwarded; all other frames (audio, control) are dropped.
- Parameters:
frame – The frame to serialize.
- Returns:
JSON text for an RTVI server message, or
Noneto drop the frame.
- async deserialize(data: str | bytes) Frame | None[source]
Deserialize an inbound JSON RTVI message into a frame.
- Parameters:
data – JSON text (or bytes) sent by the harness.
- Returns:
An
LLMMessagesUpdateFramefor the eval-context control message, anInputTransportMessageFramewrapping any other RTVI message, orNoneif the payload is not a valid RTVI message.