Skip to content
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

Ruthless/improve metrics types 2 #474

Merged
merged 1 commit into from
Sep 20, 2024
Merged

Conversation

mattieruth
Copy link
Contributor

@mattieruth mattieruth commented Sep 18, 2024

Cleanup on aisle METRICS.

Note: See below, this is a breaking change

  1. Fleshed out MetricsFrames and broke it into a proper set of types
  2. Add model_name as a property to the AIService so that it can be
    automatically included in metrics and also remove that
    overhead from all the various services themselves

Breaking change!

Because of the types improvements, the MetricsFrame type has
changed. Each frame will have a list of metrics simlilar to before
except each item in the list will only contain one type of metric:
"ttfb", "tokens", "characters", or "processing". Previously these
fields would be in every entry but set to None if they didn't apply.

While this changes internal handling of the MetricsFrame, it does NOT
break the RTVI/daily messaging of metrics. That format remains the same.

Also. Remember to use model_name for accessing a service's current
model and set_model_name for setting it.

@mattieruth mattieruth force-pushed the ruthless/improve-metrics-types-2 branch from 4ff35b6 to 0c20e9e Compare September 18, 2024 16:56
@@ -108,6 +126,7 @@ def __init__(

# Metrics
self._metrics = FrameProcessorMetrics(name=self.name)
self._metrics_meta = {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not to self: this is an artifact of a stale version. remove.

@@ -11,6 +11,7 @@
from abc import abstractmethod
from typing import AsyncGenerator, List, Optional, Tuple

from attr import has
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self: remove (not sure why this got added)

@mattieruth mattieruth force-pushed the ruthless/improve-metrics-types-2 branch 6 times, most recently from 346f2bb to 3a79564 Compare September 18, 2024 17:11
@@ -212,7 +211,7 @@ async def process_frame(self, frame: Frame, direction: FrameDirection):
context = OpenAILLMContext.from_image_frame(frame)
elif isinstance(frame, LLMModelUpdateFrame):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theoretically, this can now move into LLMService and be another thing these processors don't have to remember to do

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

@mattieruth mattieruth force-pushed the ruthless/improve-metrics-types-2 branch 5 times, most recently from 2c815e7 to e0b6629 Compare September 19, 2024 19:16
@mattieruth mattieruth changed the base branch from main to ruthless/get-tests-running September 19, 2024 21:17
@mattieruth mattieruth marked this pull request as ready for review September 19, 2024 21:41
@mattieruth mattieruth force-pushed the ruthless/improve-metrics-types-2 branch from e0b6629 to 23af89c Compare September 19, 2024 21:44
@@ -46,6 +47,11 @@
class AIService(FrameProcessor):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.model_name: str = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we make this private and a property instead?

@property
def model_name(self):
   return self._model_name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. i think this is ready for final eyes :)

@mattieruth mattieruth force-pushed the ruthless/get-tests-running branch from 5f0a3ed to 74005fb Compare September 19, 2024 21:49
@mattieruth mattieruth force-pushed the ruthless/improve-metrics-types-2 branch from 23af89c to 01cdb6e Compare September 19, 2024 21:49
@mattieruth mattieruth force-pushed the ruthless/get-tests-running branch from 74005fb to 56a8429 Compare September 19, 2024 21:52
@mattieruth mattieruth force-pushed the ruthless/improve-metrics-types-2 branch from 01cdb6e to d84c4d7 Compare September 19, 2024 21:53
@mattieruth mattieruth force-pushed the ruthless/get-tests-running branch 2 times, most recently from bc94a8a to 50b45ac Compare September 20, 2024 00:58
@mattieruth mattieruth force-pushed the ruthless/improve-metrics-types-2 branch from d84c4d7 to 6bdf090 Compare September 20, 2024 01:04
1. Fleshed out MetricsFrames and broke it into a proper set of types
2. Add model_name as a property to the AIService so that it can be
   automatically included in metrics and also remove that
   overhead from all the various services themselves

Breaking change!

Because of the types improvements, the MetricsFrame type has
changed. Each frame will have a list of metrics simlilar to before
except each item in the list will only contain one type of metric:
"ttfb", "tokens", "characters", or "processing". Previously these
fields would be in every entry but set to None if they didn't apply.

While this changes internal handling of the MetricsFrame, it does NOT
break the RTVI/daily messaging of metrics. That format remains the same.

Also. Remember to use model_name for accessing a service's current
model and set_model_name for setting it.
@mattieruth mattieruth changed the base branch from ruthless/get-tests-running to main September 20, 2024 01:33
@mattieruth mattieruth force-pushed the ruthless/improve-metrics-types-2 branch from 6bdf090 to a4edb3d Compare September 20, 2024 01:39
@aconchillo
Copy link
Contributor

Nice!

@mattieruth
Copy link
Contributor Author

Nice!

Thanks for all the help!

@mattieruth mattieruth merged commit 58d9c84 into main Sep 20, 2024
3 checks passed
cyrilS-dev added a commit to cyrilS-dev/pipecat that referenced this pull request Sep 22, 2024
joachimchauvet added a commit to joachimchauvet/pipecat-livekit that referenced this pull request Sep 25, 2024
@aconchillo aconchillo deleted the ruthless/improve-metrics-types-2 branch October 23, 2024 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants