From 295902915191ab666289e95d7deb0eb8e2f5d40e Mon Sep 17 00:00:00 2001 From: mattie ruth backman Date: Wed, 25 Jun 2025 22:17:24 -0400 Subject: [PATCH] PR Review fixes --- src/pipecat/processors/frameworks/rtvi.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/pipecat/processors/frameworks/rtvi.py b/src/pipecat/processors/frameworks/rtvi.py index ed27311d5..a1fc9e128 100644 --- a/src/pipecat/processors/frameworks/rtvi.py +++ b/src/pipecat/processors/frameworks/rtvi.py @@ -13,7 +13,6 @@ and frame observation for the RTVI protocol. import asyncio import base64 -import time from dataclasses import dataclass from typing import ( Any, @@ -334,10 +333,14 @@ class RTVIClientMessageFrame(SystemFrame): @dataclass class RTVIServerResponseFrame(SystemFrame): - """A frame for sending messages from the client to the RTVI server. + """A frame for responding to a client RTVI message. - This frame is meant for custom messaging from the client to the server - and expects a server-response message. + This frame should be sent in response to an RTVIClientMessageFrame + and include the original RTVIClientMessageFrame to ensure the response + is properly attributed to the original request. To respond with an error, + set the `error` field to a string describing the error. This will result + in the client receiving a `response-error` message instead of a + `server-response` message. """ client_msg: RTVIClientMessageFrame @@ -353,9 +356,9 @@ class RTVIRawServerResponseData(BaseModel): class RTVIServerResponse(BaseModel): - """A response message from the client to the RTVI server. + """The RTVI-formatted message response from the server to the client. - This message is used to respond to custom messages sent by the server. + This message is used to respond to custom messages sent by the client. """ label: RTVIMessageLiteral = RTVI_MESSAGE_LABEL @@ -564,6 +567,8 @@ class RTVIBotReadyData(BaseModel): """ version: str + # The config field is deprecated and will not be included if + # the client's rtvi version is 1.0.0 or higher. config: Optional[List[RTVIServiceConfig]] = None about: Optional[Mapping[str, Any]] = None @@ -1428,12 +1433,12 @@ class RTVIProcessor(FrameProcessor): await self._handle_function_call_result(data) case "append-to-context": data = RTVIAppendToContextData.model_validate(message.data) - await self._handle_update_context(data) + await self._handle_update_context(data, message.id) case "raw-audio" | "raw-audio-batch": await self._handle_audio_buffer(message.data) case _: - await self._send_error_response(message.id, f"UNSUPPORTED type {message.type}") + await self._send_error_response(message.id, f"Unsupported type {message.type}") except ValidationError as e: await self._send_error_response(message.id, f"Invalid message: {e}")