PR Review fixes

This commit is contained in:
mattie ruth backman
2025-06-25 22:17:24 -04:00
committed by Mattie Ruth
parent e590441b7b
commit 2959029151

View File

@@ -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}")