mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-16 23:41:43 +00:00
* test(e2e): read datadog log delivery back from the real datadog api (#33604) * test(e2e): read datadog log delivery back from the real datadog api * test(e2e): compare datadog-read cost with math.isclose, not bit-equality The response_cost now round-trips through DataDog's attribute indexing pipeline, whose float serialization is not guaranteed to preserve the exact bit pattern the proxy shipped. rel_tol=1e-9 (equal to 9 significant digits) still fails on any real cost discrepancy while tolerating representation drift. Addresses the Greptile P2 on this PR. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(e2e): widen the duplicate-settle window to 30s for real DataDog Against the local sink one poll interval (5s) after the first hit was enough to catch a same-call duplicate, because both events arrived in the same flush batch. Against real DataDog, ingestion jitter can make one call's two events searchable tens of seconds apart, so a 5s settle could let the LIT-4447 duplicate slip past the exactly-one assertion. The reader now keeps re-reading for DD_SETTLE_SECONDS (default 30s, env-overridable via E2E_DD_SETTLE_SECONDS) after the first event appears, returning early only when a duplicate is already visible - more waiting cannot clear it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(e2e): point UI tests at dashboard service; register complexity router Stage gateway 404s /ui; the Next.js dashboard is litellm-ui:3000. Drive playwright against E2E_UI_BASE_URL and wait on login placeholders after client render. Register complexity-smart-router via /model/new when the proxy does not already list it so stage matches compose config * docs(e2e): clarify E2E_UI_BASE_URL should be ALB when ingress splits UI * docs(e2e): prefer single path-routing host for control plane and UI CONTROL_PLANE and UI already default to PROXY_BASE_URL; clarify that stage should set one ALB host rather than three endpoints * fix(e2e): always capture complexity router model_id for teardown Split /model/new from the data-plane wait so a propagation timeout still deletes the control-plane registration (greptile orphan-model concern) * fix(e2e): click exact Login button so SSO control is not matched Playwright strict mode matched both Login and Login with SSO * fix(router): score complexity by difficulty not request length The LLM classifier prompt treated short wording as SIMPLE, so probes like "Is P equal to NP?" stayed on the SIMPLE backend even though the classifier ran. Judge intellectual difficulty so short hard questions route higher * fix(e2e): open key edit via Key ID and wait for team models Key Alias text is not the row open control on the virtual keys table; KeyInfoView opens from the Key ID button in that row. Also wait for a real team model in the edit Models dropdown so we do not race the async availableModels fetch that only has All Team Models on first paint * fix(e2e): keep settled DD events on empty search; bump mcp for OSV Do not let a transient empty DataDog search wipe events already seen in the settle window (Greptile P1). Make the logs-search from window env-overridable via E2E_DD_SEARCH_FROM (Greptile P2). Prefer the mono Key ID button when opening key edit. Bump mcp 1.26.0 -> 1.28.1 so OSV clears the three high GHSA findings on the staging PR * revert: drop mcp lock bump from e2e staging PR OSV mcp upgrade is unrelated to the e2e fixes; leave the dep pin alone --------- Co-authored-by: yucheng-berri <yucheng@berri.ai> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
222 lines
7.1 KiB
Python
222 lines
7.1 KiB
Python
"""Provider x routing-scenario matrix for the batches lifecycle e2e."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import base64
|
|
import os
|
|
from dataclasses import dataclass
|
|
from typing import Literal
|
|
|
|
from models import LiteLLMParamsBody
|
|
|
|
|
|
def _env_ref(*names: str) -> str:
|
|
for name in names:
|
|
value = os.environ.get(name)
|
|
if value is not None and value.strip() != "":
|
|
return f"os.environ/{name}"
|
|
return f"os.environ/{names[0]}"
|
|
|
|
Scenario = Literal["encoded", "unified", "model_param", "provider_fallback"]
|
|
|
|
IdShape = Literal["managed", "model_encoded", "raw"]
|
|
|
|
SCENARIOS: tuple[Scenario, ...] = (
|
|
"encoded",
|
|
"unified",
|
|
"model_param",
|
|
"provider_fallback",
|
|
)
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class Provider:
|
|
name: str
|
|
model: str
|
|
raw_model: str
|
|
can_cancel: bool
|
|
can_list: bool
|
|
|
|
def litellm_params(self) -> LiteLLMParamsBody:
|
|
match self.name:
|
|
case "openai":
|
|
return LiteLLMParamsBody(
|
|
model="openai/gpt-4o-mini",
|
|
api_key="os.environ/OPENAI_API_KEY",
|
|
)
|
|
case "azure":
|
|
return LiteLLMParamsBody(
|
|
model="azure/gpt-5.4-mini-batch",
|
|
api_base="os.environ/AZURE_API_BASE",
|
|
api_key="os.environ/AZURE_API_KEY",
|
|
api_version="2025-04-01-preview",
|
|
)
|
|
case "vertex_ai":
|
|
return LiteLLMParamsBody(
|
|
model="vertex_ai/gemini-2.5-flash",
|
|
vertex_project="os.environ/VERTEXAI_PROJECT",
|
|
vertex_location="us-central1",
|
|
vertex_credentials="os.environ/VERTEXAI_CREDENTIALS",
|
|
gcs_bucket_name="os.environ/GCS_BUCKET_NAME",
|
|
bucket_name="os.environ/GCS_BUCKET_NAME",
|
|
)
|
|
case "bedrock":
|
|
return LiteLLMParamsBody(
|
|
model="bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0",
|
|
aws_access_key_id="os.environ/AWS_ACCESS_KEY_ID",
|
|
aws_secret_access_key="os.environ/AWS_SECRET_ACCESS_KEY",
|
|
aws_region_name="os.environ/AWS_REGION",
|
|
s3_region_name="os.environ/AWS_REGION",
|
|
s3_bucket_name=_env_ref("AWS_BATCH_S3_BUCKET", "AWS_S3_BUCKET_NAME"),
|
|
s3_access_key_id="os.environ/AWS_ACCESS_KEY_ID",
|
|
s3_secret_access_key="os.environ/AWS_SECRET_ACCESS_KEY",
|
|
aws_batch_role_arn="os.environ/AWS_BATCH_ROLE_ARN",
|
|
)
|
|
case _:
|
|
raise ValueError(f"unknown batch provider: {self.name!r}")
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class Capability:
|
|
provider: str
|
|
model: str
|
|
raw_model: str
|
|
scenario: Scenario
|
|
can_cancel: bool
|
|
can_list: bool
|
|
|
|
@property
|
|
def id(self) -> str:
|
|
return f"{self.provider}-{self.scenario}"
|
|
|
|
@property
|
|
def jsonl_model(self) -> str:
|
|
return self.model if self.scenario == "unified" else self.raw_model
|
|
|
|
|
|
PROVIDERS: tuple[Provider, ...] = (
|
|
Provider("openai", "openai-batch", "gpt-4o-mini", can_cancel=True, can_list=True),
|
|
Provider("azure", "azure-batch", "gpt-5.4-mini-batch", can_cancel=True, can_list=True),
|
|
Provider(
|
|
"vertex_ai", "vertex-batch", "gemini-2.5-flash", can_cancel=True, can_list=True
|
|
),
|
|
Provider(
|
|
"bedrock",
|
|
"bedrock-batch",
|
|
"bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0",
|
|
can_cancel=False,
|
|
can_list=False,
|
|
),
|
|
)
|
|
|
|
BEDROCK_SCENARIOS: tuple[Scenario, ...] = ("unified",)
|
|
|
|
|
|
def scenarios_for_provider(provider: Provider) -> tuple[Scenario, ...]:
|
|
if provider.name == "bedrock":
|
|
return BEDROCK_SCENARIOS
|
|
return SCENARIOS
|
|
|
|
|
|
CAPABILITIES: tuple[Capability, ...] = tuple(
|
|
Capability(p.name, p.model, p.raw_model, scenario, p.can_cancel, p.can_list)
|
|
for p in PROVIDERS
|
|
for scenario in scenarios_for_provider(p)
|
|
)
|
|
|
|
|
|
def raw_id_matches_provider(provider: str, batch_id: str) -> bool:
|
|
if provider in ("openai", "azure"):
|
|
return batch_id.startswith("batch")
|
|
if provider == "vertex_ai":
|
|
return (
|
|
batch_id.startswith("projects/")
|
|
or "batchPredictionJobs" in batch_id
|
|
or batch_id.isdigit()
|
|
)
|
|
if provider == "bedrock":
|
|
return batch_id.startswith("arn:aws:bedrock:")
|
|
return True
|
|
|
|
|
|
FILE_ID_SHAPE: dict[Scenario, IdShape] = {
|
|
"encoded": "model_encoded",
|
|
"unified": "managed",
|
|
"model_param": "raw",
|
|
"provider_fallback": "raw",
|
|
}
|
|
|
|
BATCH_ID_SHAPE: dict[Scenario, IdShape] = {
|
|
"encoded": "model_encoded",
|
|
"unified": "managed",
|
|
"model_param": "model_encoded",
|
|
"provider_fallback": "raw",
|
|
}
|
|
|
|
|
|
def _b64_decode(value: str) -> str:
|
|
padded = value + "=" * (-len(value) % 4)
|
|
try:
|
|
return base64.urlsafe_b64decode(padded).decode()
|
|
except Exception:
|
|
return ""
|
|
|
|
|
|
def is_managed_id(id_str: str) -> bool:
|
|
return _b64_decode(id_str).startswith("litellm_proxy")
|
|
|
|
|
|
def is_model_encoded_id(id_str: str) -> bool:
|
|
for prefix in ("file-", "batch_"):
|
|
if id_str.startswith(prefix):
|
|
decoded = _b64_decode(id_str[len(prefix) :])
|
|
return decoded.startswith("litellm:") and ";model," in decoded
|
|
return False
|
|
|
|
|
|
def matches_id_shape(shape: IdShape, id_str: str) -> bool:
|
|
if shape == "managed":
|
|
return is_managed_id(id_str)
|
|
if shape == "model_encoded":
|
|
return is_model_encoded_id(id_str)
|
|
return not is_managed_id(id_str) and not is_model_encoded_id(id_str)
|
|
|
|
|
|
def coverage_cells_for_lifecycle(cap: Capability) -> tuple[str, ...]:
|
|
"""Registry cell ids that the parametrized lifecycle test covers for one capability.
|
|
|
|
OpenAI has per-scenario cells plus granular create/retrieve/cancel/list/file
|
|
cells. Other providers have one basic cell each. File-upload cells for the
|
|
batch-backing path are included when the lifecycle uploads for that provider.
|
|
"""
|
|
match cap.provider:
|
|
case "openai":
|
|
cells = (
|
|
f"llm.batches.openai_{cap.scenario}.basic.nonstream.works",
|
|
"llm.batches.openai.create.nonstream.works",
|
|
"llm.batches.openai.retrieve.nonstream.works",
|
|
"llm.batches.openai.file_lifecycle.nonstream.works",
|
|
"llm.files.openai.upload.nonstream.works",
|
|
)
|
|
if cap.can_cancel:
|
|
cells = (*cells, "llm.batches.openai.cancel.nonstream.works")
|
|
if cap.can_list:
|
|
cells = (*cells, "llm.batches.openai.list.nonstream.works")
|
|
return cells
|
|
case "azure":
|
|
return (
|
|
"llm.batches.azure_openai.basic.nonstream.works",
|
|
"llm.files.azure_openai.upload.nonstream.works",
|
|
)
|
|
case "vertex_ai":
|
|
return (
|
|
"llm.batches.vertex.basic.nonstream.works",
|
|
"llm.files.vertex.upload.nonstream.works",
|
|
)
|
|
case "bedrock":
|
|
return (
|
|
"llm.batches.bedrock.basic.nonstream.works",
|
|
"llm.files.bedrock.upload.nonstream.works",
|
|
)
|
|
case _:
|
|
return ()
|