-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fleshed out MetricsFrames and their various types to enforce better #468
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import Optional | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is a new module, we need an empty |
||
from pydantic import BaseModel | ||
|
||
|
||
class MetricsData(BaseModel): | ||
processor: str | ||
|
||
|
||
class TTFBMetricsData(MetricsData): | ||
value: float | ||
model: Optional[str] = None | ||
|
||
|
||
class ProcessingMetricsData(MetricsData): | ||
value: float | ||
model: Optional[str] = None | ||
|
||
|
||
class LLMUsageMetricsData(MetricsData): | ||
model: str | ||
prompt_tokens: int | ||
completion_tokens: int | ||
total_tokens: int | ||
|
||
|
||
class CacheUsageMetricsData(LLMUsageMetricsData): | ||
cache_read_input_tokens: int | ||
cache_creation_input_tokens: int | ||
|
||
|
||
class TTSUsageMetricsData(MetricsData): | ||
processor: str | ||
model: Optional[str] = None | ||
value: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
from abc import abstractmethod | ||
from typing import AsyncGenerator, List, Optional, Tuple | ||
|
||
from attr import has | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note to self: remove (not sure why this got added) |
||
from pipecat.frames.frames import ( | ||
AudioRawFrame, | ||
CancelFrame, | ||
|
@@ -490,17 +491,6 @@ def __init__(self, **kwargs): | |
async def run_image_gen(self, prompt: str) -> AsyncGenerator[Frame, None]: | ||
pass | ||
|
||
async def process_frame(self, frame: Frame, direction: FrameDirection): | ||
await super().process_frame(frame, direction) | ||
|
||
if isinstance(frame, TextFrame): | ||
await self.push_frame(frame, direction) | ||
await self.start_processing_metrics() | ||
await self.process_generator(self.run_image_gen(frame.text)) | ||
await self.stop_processing_metrics() | ||
else: | ||
await self.push_frame(frame, direction) | ||
|
||
|
||
class VisionService(AIService): | ||
"""VisionService is a base class for vision services.""" | ||
|
@@ -512,13 +502,3 @@ def __init__(self, **kwargs): | |
@abstractmethod | ||
async def run_vision(self, frame: VisionImageRawFrame) -> AsyncGenerator[Frame, None]: | ||
pass | ||
|
||
async def process_frame(self, frame: Frame, direction: FrameDirection): | ||
await super().process_frame(frame, direction) | ||
|
||
if isinstance(frame, VisionImageRawFrame): | ||
await self.start_processing_metrics() | ||
await self.process_generator(self.run_vision(frame)) | ||
await self.stop_processing_metrics() | ||
else: | ||
await self.push_frame(frame, direction) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the same changes by autopep8. I think they broke something. If we do this change the output will be messed up with carriage return. What I do, before committing, is just revert only these changes. Very annoying, but I haven't found a better way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one actually seems right to me (or almost right. this is wrapping at 108 😕 ). shouldn't it wrap at 100 chars? meanwhile, I agree.. something is up with the formatter because it seems inconsistent