PR Review fixes
This commit is contained in:
committed by
Mattie Ruth
parent
e590441b7b
commit
2959029151
@@ -13,7 +13,6 @@ and frame observation for the RTVI protocol.
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import base64
|
import base64
|
||||||
import time
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
@@ -334,10 +333,14 @@ class RTVIClientMessageFrame(SystemFrame):
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class RTVIServerResponseFrame(SystemFrame):
|
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
|
This frame should be sent in response to an RTVIClientMessageFrame
|
||||||
and expects a server-response message.
|
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
|
client_msg: RTVIClientMessageFrame
|
||||||
@@ -353,9 +356,9 @@ class RTVIRawServerResponseData(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class RTVIServerResponse(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
|
label: RTVIMessageLiteral = RTVI_MESSAGE_LABEL
|
||||||
@@ -564,6 +567,8 @@ class RTVIBotReadyData(BaseModel):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
version: str
|
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
|
config: Optional[List[RTVIServiceConfig]] = None
|
||||||
about: Optional[Mapping[str, Any]] = None
|
about: Optional[Mapping[str, Any]] = None
|
||||||
|
|
||||||
@@ -1428,12 +1433,12 @@ class RTVIProcessor(FrameProcessor):
|
|||||||
await self._handle_function_call_result(data)
|
await self._handle_function_call_result(data)
|
||||||
case "append-to-context":
|
case "append-to-context":
|
||||||
data = RTVIAppendToContextData.model_validate(message.data)
|
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":
|
case "raw-audio" | "raw-audio-batch":
|
||||||
await self._handle_audio_buffer(message.data)
|
await self._handle_audio_buffer(message.data)
|
||||||
|
|
||||||
case _:
|
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:
|
except ValidationError as e:
|
||||||
await self._send_error_response(message.id, f"Invalid message: {e}")
|
await self._send_error_response(message.id, f"Invalid message: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user