mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
fix(lint): fix PLR0913 violations in prometheus/milvus/cooldown_callbacks
- set_litellm_deployment_state: accept UserAPIKeyLabelValues instead of 6 individual params - increment_deployment_cooled_down: accept enum_values + exception_status (2 params) - milvus store: reorder params to only include used ones (chunks, embeddings, filename, **_) - cooldown_callbacks: update call site to pass UserAPIKeyLabelValues Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f607966982
commit
60c6e77f58
3 changed files with 42 additions and 37 deletions
|
|
@ -2739,25 +2739,16 @@ class PrometheusLogger(CustomLogger):
|
|||
def set_litellm_deployment_state(
|
||||
self,
|
||||
state: int,
|
||||
litellm_model_name: str,
|
||||
model_id: Optional[str],
|
||||
api_base: Optional[str],
|
||||
api_provider: str,
|
||||
model_group: str | None = None,
|
||||
):
|
||||
enum_values: UserAPIKeyLabelValues,
|
||||
) -> None:
|
||||
"""
|
||||
Set the deployment state.
|
||||
"""
|
||||
### get labels
|
||||
_labels = prometheus_label_factory(
|
||||
supported_enum_labels=self.get_labels_for_metric(metric_name="litellm_deployment_state"),
|
||||
enum_values=UserAPIKeyLabelValues(
|
||||
litellm_model_name=litellm_model_name,
|
||||
model_group=model_group,
|
||||
model_id=model_id,
|
||||
api_base=api_base,
|
||||
api_provider=api_provider,
|
||||
supported_enum_labels=self.get_labels_for_metric(
|
||||
metric_name="litellm_deployment_state"
|
||||
),
|
||||
enum_values=enum_values,
|
||||
)
|
||||
self.litellm_deployment_state.labels(**_labels).set(state)
|
||||
|
||||
|
|
@ -2770,7 +2761,14 @@ class PrometheusLogger(CustomLogger):
|
|||
model_group: str | None = None,
|
||||
):
|
||||
self.set_litellm_deployment_state(
|
||||
0, litellm_model_name, model_id, api_base, api_provider, model_group
|
||||
0,
|
||||
UserAPIKeyLabelValues(
|
||||
litellm_model_name=litellm_model_name,
|
||||
model_group=model_group,
|
||||
model_id=model_id,
|
||||
api_base=api_base,
|
||||
api_provider=api_provider,
|
||||
),
|
||||
)
|
||||
|
||||
def set_deployment_partial_outage(
|
||||
|
|
@ -2782,7 +2780,14 @@ class PrometheusLogger(CustomLogger):
|
|||
model_group: str | None = None,
|
||||
):
|
||||
self.set_litellm_deployment_state(
|
||||
1, litellm_model_name, model_id, api_base, api_provider, model_group
|
||||
1,
|
||||
UserAPIKeyLabelValues(
|
||||
litellm_model_name=litellm_model_name,
|
||||
model_group=model_group,
|
||||
model_id=model_id,
|
||||
api_base=api_base,
|
||||
api_provider=api_provider,
|
||||
),
|
||||
)
|
||||
|
||||
def set_deployment_complete_outage(
|
||||
|
|
@ -2794,18 +2799,21 @@ class PrometheusLogger(CustomLogger):
|
|||
model_group: str | None = None,
|
||||
):
|
||||
self.set_litellm_deployment_state(
|
||||
2, litellm_model_name, model_id, api_base, api_provider, model_group
|
||||
2,
|
||||
UserAPIKeyLabelValues(
|
||||
litellm_model_name=litellm_model_name,
|
||||
model_group=model_group,
|
||||
model_id=model_id,
|
||||
api_base=api_base,
|
||||
api_provider=api_provider,
|
||||
),
|
||||
)
|
||||
|
||||
def increment_deployment_cooled_down(
|
||||
self,
|
||||
litellm_model_name: str,
|
||||
model_id: str,
|
||||
api_base: str,
|
||||
api_provider: str,
|
||||
enum_values: UserAPIKeyLabelValues,
|
||||
exception_status: str,
|
||||
model_group: str | None = None,
|
||||
):
|
||||
) -> None:
|
||||
"""
|
||||
increment metric when litellm.Router / load balancing logic places a deployment in cool down
|
||||
"""
|
||||
|
|
@ -2814,12 +2822,7 @@ class PrometheusLogger(CustomLogger):
|
|||
metric_name="litellm_deployment_cooled_down"
|
||||
),
|
||||
enum_values=UserAPIKeyLabelValues(
|
||||
litellm_model_name=litellm_model_name,
|
||||
model_group=model_group,
|
||||
model_id=model_id,
|
||||
api_base=api_base,
|
||||
api_provider=api_provider,
|
||||
exception_status=exception_status,
|
||||
**{**enum_values.__dict__, "exception_status": exception_status}
|
||||
),
|
||||
)
|
||||
self.litellm_deployment_cooled_down.labels(**_labels).inc()
|
||||
|
|
|
|||
|
|
@ -217,11 +217,10 @@ class MilvusRAGIngestion(BaseRAGIngestion):
|
|||
|
||||
async def store(
|
||||
self,
|
||||
file_content: bytes | None,
|
||||
filename: str | None,
|
||||
chunks: list[str],
|
||||
embeddings: list[list[float]] | None,
|
||||
**_: object, # absorbs content_type and any extra base-class params
|
||||
filename: str | None = None,
|
||||
**_: object,
|
||||
) -> tuple[str | None, str | None]:
|
||||
"""
|
||||
Insert chunks + embeddings into a Milvus collection.
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from typing import TYPE_CHECKING, Any, Optional, Union
|
|||
|
||||
import litellm
|
||||
from litellm._logging import verbose_logger
|
||||
from litellm.types.integrations.prometheus import UserAPIKeyLabelValues
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from litellm.router import Router as _Router
|
||||
|
|
@ -74,12 +75,14 @@ async def router_cooldown_event_callback(
|
|||
)
|
||||
|
||||
prometheusLogger.increment_deployment_cooled_down(
|
||||
litellm_model_name=litellm_model_name,
|
||||
model_id=model_id,
|
||||
api_base=_api_base,
|
||||
api_provider=llm_provider,
|
||||
enum_values=UserAPIKeyLabelValues(
|
||||
litellm_model_name=litellm_model_name,
|
||||
model_id=model_id,
|
||||
api_base=_api_base,
|
||||
api_provider=llm_provider,
|
||||
model_group=_model_name,
|
||||
),
|
||||
exception_status=str(exception_status),
|
||||
model_group=_model_name,
|
||||
)
|
||||
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue