copilot feedback
This commit is contained in:
committed by
Mattie Ruth
parent
158424aa28
commit
49fba5209c
@@ -65,7 +65,7 @@ class RTVIServerResponseFrame(SystemFrame):
|
|||||||
and include the original RTVIClientMessageFrame to ensure the response
|
and include the original RTVIClientMessageFrame to ensure the response
|
||||||
is properly attributed to the original request. To respond with an error,
|
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
|
set the `error` field to a string describing the error. This will result
|
||||||
in the client receiving a `response-error` message instead of a
|
in the client receiving an `error-response` message instead of a
|
||||||
`server-response` message.
|
`server-response` message.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ server messages instead.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import (
|
from typing import (
|
||||||
|
TYPE_CHECKING,
|
||||||
Any,
|
Any,
|
||||||
Awaitable,
|
Awaitable,
|
||||||
Callable,
|
Callable,
|
||||||
@@ -26,6 +27,9 @@ from pydantic import BaseModel, Field, PrivateAttr
|
|||||||
|
|
||||||
import pipecat.processors.frameworks.rtvi.models_v1 as RTVI
|
import pipecat.processors.frameworks.rtvi.models_v1 as RTVI
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from pipecat.processors.frameworks.rtvi.processor import RTVIProcessor
|
||||||
|
|
||||||
ActionResult = Union[bool, int, float, str, list, dict]
|
ActionResult = Union[bool, int, float, str, list, dict]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ class RTVIObserver(BaseObserver):
|
|||||||
"""Send an RTVI message.
|
"""Send an RTVI message.
|
||||||
|
|
||||||
By default, we push a transport frame. But this function can be
|
By default, we push a transport frame. But this function can be
|
||||||
overriden by subclass to send RTVI messages in different ways.
|
overridden by subclass to send RTVI messages in different ways.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
model: The message to send.
|
model: The message to send.
|
||||||
@@ -539,15 +539,15 @@ class RTVIObserver(BaseObserver):
|
|||||||
return
|
return
|
||||||
|
|
||||||
text = frame.text
|
text = frame.text
|
||||||
type = frame.aggregated_by
|
agg_type = frame.aggregated_by
|
||||||
for aggregation_type, transform in self._aggregation_transforms:
|
for aggregation_type, transform in self._aggregation_transforms:
|
||||||
if aggregation_type == type or aggregation_type == "*":
|
if aggregation_type == agg_type or aggregation_type == "*":
|
||||||
text = await transform(text, type)
|
text = await transform(text, agg_type)
|
||||||
|
|
||||||
isTTS = isinstance(frame, TTSTextFrame)
|
isTTS = isinstance(frame, TTSTextFrame)
|
||||||
if self._params.bot_output_enabled:
|
if self._params.bot_output_enabled:
|
||||||
message = RTVI.BotOutputMessage(
|
message = RTVI.BotOutputMessage(
|
||||||
data=RTVI.BotOutputMessageData(text=text, spoken=isTTS, aggregated_by=type)
|
data=RTVI.BotOutputMessageData(text=text, spoken=isTTS, aggregated_by=agg_type)
|
||||||
)
|
)
|
||||||
await self.send_rtvi_message(message)
|
await self.send_rtvi_message(message)
|
||||||
|
|
||||||
|
|||||||
@@ -566,10 +566,6 @@ class RTVIProcessor(FrameProcessor):
|
|||||||
|
|
||||||
async def _handle_client_message(self, msg_id: str, data: RTVI.RawClientMessageData):
|
async def _handle_client_message(self, msg_id: str, data: RTVI.RawClientMessageData):
|
||||||
"""Handle a client message frame."""
|
"""Handle a client message frame."""
|
||||||
if not data:
|
|
||||||
await self._send_error_response(msg_id, "Malformed client message")
|
|
||||||
return
|
|
||||||
|
|
||||||
# Create a RTVIClientMessageFrame to push the message
|
# Create a RTVIClientMessageFrame to push the message
|
||||||
frame = RTVIClientMessageFrame(msg_id=msg_id, type=data.t, data=data.d)
|
frame = RTVIClientMessageFrame(msg_id=msg_id, type=data.t, data=data.d)
|
||||||
await self.push_frame(frame)
|
await self.push_frame(frame)
|
||||||
|
|||||||
Reference in New Issue
Block a user