The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(prometheus): remove dead prometheus_label_factory call; apply Black
shivam1170bd55c976
diff --git a/litellm/integrations/prometheus.py b/litellm/integrations/prometheus.pyindex f4fa1e6c036..723b142dfad 100644--- a/litellm/integrations/prometheus.py+++ b/litellm/integrations/prometheus.py@@ -51,6 +51,7 @@ if TYPE_CHECKING:else:AsyncIOScheduler = Any+class PrometheusLogger(CustomLogger):# Class variables or attributes@@ -991,9 +992,7 @@ class PrometheusLogger(CustomLogger):amount: float = 1.0,) -> None:_labels = prometheus_label_factory(- supported_enum_labels=self.get_labels_for_metric(- metric_name=metric_name- ),+ supported_enum_labels=self.get_labels_for_metric(metric_name=metric_name),enum_values=enum_values,label_context=label_context,)@@ -1118,7 +1117,9 @@ class PrometheusLogger(CustomLogger):user_api_key = hash_token(user_api_key)- label_context = PrometheusLabelFactoryContext(enum_values) #amortized per request.+ label_context = PrometheusLabelFactoryContext(+ enum_values+ ) # amortized per request.# increment total LLM requests and spend metricself._increment_top_level_request_and_spend_metrics(@@ -1791,11 +1792,6 @@ class PrometheusLogger(CustomLogger):else None),)- _labels = prometheus_label_factory(- supported_enum_labels=self.get_labels_for_metric(- metric_name="litellm_proxy_failed_requests_metric"- ),- )_label_ctx = PrometheusLabelFactoryContext(enum_values)PrometheusLogger._inc_labeled_counter(self,@@ -3495,7 +3491,9 @@ def _prometheus_labels_from_context(}if UserAPIKeyLabelNames.END_USER.value in filtered_labels:- filtered_labels[UserAPIKeyLabelNames.END_USER.value] = ctx.get_resolved_end_user()+ filtered_labels[UserAPIKeyLabelNames.END_USER.value] = (+ ctx.get_resolved_end_user()+ )for sk, val in ctx._custom_by_sanitized_key.items():if sk in supported_enum_labels:diff --git a/litellm/integrations/prometheus_helpers.py b/litellm/integrations/prometheus_helpers.pyindex 34f4855863e..784ab524dd5 100644--- a/litellm/integrations/prometheus_helpers.py+++ b/litellm/integrations/prometheus_helpers.py@@ -51,8 +51,7 @@ class PrometheusLabelFactoryContext:self.enum_values = enum_valuesenum_dict = enum_values.model_dump()self._sanitized_enum: Dict[str, Optional[str]] = {- k: _sanitize_prometheus_label_value(v)- for k, v in enum_dict.items()+ k: _sanitize_prometheus_label_value(v) for k, v in enum_dict.items()}self._custom_by_sanitized_key: Dict[str, Optional[str]] = {}if enum_values.custom_metadata_labels is not None:diff --git a/litellm/llms/github_copilot/authenticator.py b/litellm/llms/github_copilot/authenticator.pyindex f4698861edc..9de2987b9f6 100644--- a/litellm/llms/github_copilot/authenticator.py+++ b/litellm/llms/github_copilot/authenticator.py@@ -294,9 +294,7 @@ class Authenticator:access_token_url = os.getenv("GITHUB_COPILOT_ACCESS_TOKEN_URL", DEFAULT_GITHUB_ACCESS_TOKEN_URL)- client_id = os.getenv(- "GITHUB_COPILOT_CLIENT_ID", DEFAULT_GITHUB_CLIENT_ID- )+ client_id = os.getenv("GITHUB_COPILOT_CLIENT_ID", DEFAULT_GITHUB_CLIENT_ID)for attempt in range(max_attempts):try:diff --git a/litellm/passthrough/utils.py b/litellm/passthrough/utils.pyindex 5dde13f0078..d39a0dda152 100644--- a/litellm/passthrough/utils.py+++ b/litellm/passthrough/utils.py@@ -79,7 +79,9 @@ class BasePassthroughUtils:for header_name, header_value in request_headers.items():if header_name.lower().startswith(PASS_THROUGH_HEADER_PREFIX):# Strip the 'x-pass-' prefix and normalize to lowercase- actual_header_name = header_name[len(PASS_THROUGH_HEADER_PREFIX) :].lower()+ actual_header_name = header_name[+ len(PASS_THROUGH_HEADER_PREFIX) :+ ].lower()if actual_header_name in _PASS_THROUGH_PROTECTED_HEADERS or any(actual_header_name.startswith(p)for p in _PASS_THROUGH_PROTECTED_HEADER_PREFIXESdiff --git a/litellm/types/integrations/prometheus.py b/litellm/types/integrations/prometheus.pyindex 338c5a79ce6..43a287f29bc 100644--- a/litellm/types/integrations/prometheus.py+++ b/litellm/types/integrations/prometheus.py@@ -784,7 +784,7 @@ class UserAPIKeyLabelValues:org_id: Optional[str] = Noneorg_alias: Optional[str] = None- #Added for test compatibility.+ # Added for test compatibility.def __init__(self, **kwargs: Any) -> None:"""Match former Pydantic behavior: unknown keys are ignored; ``api_key_hash`` maps to