Conversation
…api-base-and-fallbacks-geanai-4264
|
|
||
| def valid_purposes_for_service_type(self, service_type: str) -> list[str]: | ||
| """Return valid purpose values for a service type (empty if purpose not used).""" | ||
| return self.service_type_purposes.get(service_type, []) |
Collaborator
There was a problem hiding this comment.
Suggested change
| return self.service_type_purposes.get(service_type, {}) |
Collaborator
There was a problem hiding this comment.
Or we could remove the second parameter entirely since it's explicitly defined above, wdyt?
| fallbacks = _safe_int_header(headers, LITELLM_HEADER_ATTEMPTED_FALLBACKS) | ||
| retries = _safe_int_header(headers, LITELLM_HEADER_ATTEMPTED_RETRIES) | ||
| duration_ms = _safe_float_header(headers, LITELLM_HEADER_RESPONSE_DURATION_MS) | ||
| if duration_ms is not None and duration_ms < 0: |
Collaborator
There was a problem hiding this comment.
Does LiteLLM ever return a negative value here?
| float(snapshot.attempted_fallbacks) | ||
| ) | ||
| metrics.litellm_attempted_retries.labels(**labels_base).observe( | ||
| float(snapshot.attempted_retries) |
Collaborator
There was a problem hiding this comment.
This is fine as an int right?
| fallback_used=fallback_used, | ||
| ).inc() | ||
| metrics.litellm_attempted_fallbacks.labels(**labels_base).observe( | ||
| float(snapshot.attempted_fallbacks) |
Collaborator
There was a problem hiding this comment.
This is fine as an int right?
| if raw is None: | ||
| return 0 | ||
| try: | ||
| return int(float(str(raw).strip())) |
Collaborator
There was a problem hiding this comment.
suggestion: We should probably either pick int or float, not both
Collaborator
There was a problem hiding this comment.
Since it's _safe_int_header, int is best 👍
Collaborator
|
Looks good to me, just a few comments 👍 |
Co-authored-by: Noah Podgurski <42069075+noahpodgurski@users.noreply.github.com>
…thub.com:Firefox-AI/MLPA into feat-tracking-api-base-and-fallbacks-geanai-4264
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What's new:
Add LiteLLM response header parser to extra extra metrics
Jira: https://mozilla-hub.atlassian.net/browse/GENAI-4264
Note that vertex_ai doesn't return api_base header, but TogetherAI and RayServe will return it
New metrics
successful completions only, labels include requested model, backend, service type, purpose, and fallback_used where applicable:
QA:
tests old and new ✅
Local QA ✅