From 05d4fba551aace80062644e28fe359866702bde9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Tue, 23 Jul 2024 10:50:56 -0700 Subject: [PATCH] processors(rtvi): send initial empty metrics --- src/pipecat/processors/frameworks/rtvi.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pipecat/processors/frameworks/rtvi.py b/src/pipecat/processors/frameworks/rtvi.py index f9e76fb6d..f7bd170c2 100644 --- a/src/pipecat/processors/frameworks/rtvi.py +++ b/src/pipecat/processors/frameworks/rtvi.py @@ -19,6 +19,7 @@ LLMMessagesAppendFrame, LLMMessagesUpdateFrame, LLMModelUpdateFrame, + MetricsFrame, StartFrame, SystemFrame, TTSSpeakFrame, @@ -456,6 +457,13 @@ async def _handle_setup(self, setup: RTVISetup | None): start_frame = dataclasses.replace(self._start_frame) await self.push_frame(start_frame) + # Send new initial metrics with the new processors + processors = parent.processors_with_metrics() + processors.extend(self._pipeline.processors_with_metrics()) + ttfb = [{"name": p.name, "time": 0.0} for p in processors] + processing = [{"name": p.name, "time": 0.0} for p in processors] + await self.push_frame(MetricsFrame(ttfb=ttfb, processing=processing)) + message = RTVIBotReady() frame = TransportMessageFrame(message=message.model_dump(exclude_none=True)) await self.push_frame(frame)