Merge pull request #316 from pipecat-ai/aleix/metrics-improvements
metrics improvements
This commit is contained in:
10
CHANGELOG.md
10
CHANGELOG.md
@@ -7,11 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unrelease]
|
## [Unrelease]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `send_initial_empty_metrics` flag to `PipelineParams` to request for
|
||||||
|
initial empty metrics (zero values). True by default.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed initial metrics format. It was using the wrong keys name/time instead of
|
||||||
|
processor/value.
|
||||||
|
|
||||||
- STT services should be using ISO 8601 time format for transcription frames.
|
- STT services should be using ISO 8601 time format for transcription frames.
|
||||||
|
|
||||||
- Fix an issue that would cause Daily transport to show a stop transcription
|
- Fixed an issue that would cause Daily transport to show a stop transcription
|
||||||
error when actually none occurred.
|
error when actually none occurred.
|
||||||
|
|
||||||
## [0.0.37] - 2024-07-22
|
## [0.0.37] - 2024-07-22
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class Pipeline(BasePipeline):
|
|||||||
services = []
|
services = []
|
||||||
for p in self._processors:
|
for p in self._processors:
|
||||||
if isinstance(p, BasePipeline):
|
if isinstance(p, BasePipeline):
|
||||||
services += p.processors_with_metrics()
|
services.extend(p.processors_with_metrics())
|
||||||
elif p.can_generate_metrics():
|
elif p.can_generate_metrics():
|
||||||
services.append(p)
|
services.append(p)
|
||||||
return services
|
return services
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ from loguru import logger
|
|||||||
class PipelineParams(BaseModel):
|
class PipelineParams(BaseModel):
|
||||||
allow_interruptions: bool = False
|
allow_interruptions: bool = False
|
||||||
enable_metrics: bool = False
|
enable_metrics: bool = False
|
||||||
|
send_initial_empty_metrics: bool = True
|
||||||
report_only_initial_ttfb: bool = False
|
report_only_initial_ttfb: bool = False
|
||||||
|
|
||||||
|
|
||||||
@@ -95,8 +96,8 @@ class PipelineTask:
|
|||||||
|
|
||||||
def _initial_metrics_frame(self) -> MetricsFrame:
|
def _initial_metrics_frame(self) -> MetricsFrame:
|
||||||
processors = self._pipeline.processors_with_metrics()
|
processors = self._pipeline.processors_with_metrics()
|
||||||
ttfb = [{"name": p.name, "time": 0.0} for p in processors]
|
ttfb = [{"processor": p.name, "value": 0.0} for p in processors]
|
||||||
processing = [{"name": p.name, "time": 0.0} for p in processors]
|
processing = [{"processor": p.name, "value": 0.0} for p in processors]
|
||||||
return MetricsFrame(ttfb=ttfb, processing=processing)
|
return MetricsFrame(ttfb=ttfb, processing=processing)
|
||||||
|
|
||||||
async def _process_down_queue(self):
|
async def _process_down_queue(self):
|
||||||
@@ -106,7 +107,9 @@ class PipelineTask:
|
|||||||
report_only_initial_ttfb=self._params.report_only_initial_ttfb
|
report_only_initial_ttfb=self._params.report_only_initial_ttfb
|
||||||
)
|
)
|
||||||
await self._source.process_frame(start_frame, FrameDirection.DOWNSTREAM)
|
await self._source.process_frame(start_frame, FrameDirection.DOWNSTREAM)
|
||||||
await self._source.process_frame(self._initial_metrics_frame(), FrameDirection.DOWNSTREAM)
|
|
||||||
|
if self._params.send_initial_empty_metrics:
|
||||||
|
await self._source.process_frame(self._initial_metrics_frame(), FrameDirection.DOWNSTREAM)
|
||||||
|
|
||||||
running = True
|
running = True
|
||||||
should_cleanup = True
|
should_cleanup = True
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from pipecat.frames.frames import (
|
|||||||
LLMMessagesAppendFrame,
|
LLMMessagesAppendFrame,
|
||||||
LLMMessagesUpdateFrame,
|
LLMMessagesUpdateFrame,
|
||||||
LLMModelUpdateFrame,
|
LLMModelUpdateFrame,
|
||||||
|
MetricsFrame,
|
||||||
StartFrame,
|
StartFrame,
|
||||||
SystemFrame,
|
SystemFrame,
|
||||||
TTSSpeakFrame,
|
TTSSpeakFrame,
|
||||||
@@ -456,6 +457,13 @@ class RTVIProcessor(FrameProcessor):
|
|||||||
start_frame = dataclasses.replace(self._start_frame)
|
start_frame = dataclasses.replace(self._start_frame)
|
||||||
await self.push_frame(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 = [{"processor": p.name, "value": 0.0} for p in processors]
|
||||||
|
processing = [{"processor": p.name, "value": 0.0} for p in processors]
|
||||||
|
await self.push_frame(MetricsFrame(ttfb=ttfb, processing=processing))
|
||||||
|
|
||||||
message = RTVIBotReady()
|
message = RTVIBotReady()
|
||||||
frame = TransportMessageFrame(message=message.model_dump(exclude_none=True))
|
frame = TransportMessageFrame(message=message.model_dump(exclude_none=True))
|
||||||
await self.push_frame(frame)
|
await self.push_frame(frame)
|
||||||
|
|||||||
@@ -678,12 +678,15 @@ class DailyOutputTransport(BaseOutputTransport):
|
|||||||
await self._client.send_message(frame)
|
await self._client.send_message(frame)
|
||||||
|
|
||||||
async def send_metrics(self, frame: MetricsFrame):
|
async def send_metrics(self, frame: MetricsFrame):
|
||||||
|
metrics = {}
|
||||||
|
if frame.ttfb:
|
||||||
|
metrics["ttfb"] = frame.ttfb
|
||||||
|
if frame.processing:
|
||||||
|
metrics["processing"] = frame.processing
|
||||||
|
|
||||||
message = DailyTransportMessageFrame(message={
|
message = DailyTransportMessageFrame(message={
|
||||||
"type": "pipecat-metrics",
|
"type": "pipecat-metrics",
|
||||||
"metrics": {
|
"metrics": metrics
|
||||||
"ttfb": frame.ttfb or [],
|
|
||||||
"processing": frame.processing or [],
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
await self._client.send_message(message)
|
await self._client.send_message(message)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user