mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-29 06:33:28 +00:00
* test(decisions): audit #47508 * test(decisions): price the Databricks decision cell from its cost-map row --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
This commit is contained in:
parent
9546f9a69f
commit
889d8aec15
3 changed files with 56 additions and 5 deletions
|
|
@ -162,6 +162,37 @@ TYPESAFE_JEV_LATEST_SYSTEMONE: Final = CostTrackingTestCase(
|
|||
completion_tokens=22,
|
||||
),
|
||||
)
|
||||
TYPESAFE_JEV_PREVIEW_ANSWERED_AS_PRICED_VERSION_SYSTEMONE: Final = CostTrackingTestCase(
|
||||
name="typesafe/jev-preview-answered-as-priced-version-systemone",
|
||||
covers="quota_management.spend_tracking.systemone.logs_cost",
|
||||
model="typesafe/jev-preview",
|
||||
endpoint="/v1/systemone",
|
||||
request={
|
||||
"model": "$MODEL",
|
||||
"state": "The replacement part arrived but the wrong size.",
|
||||
"questions": {"is_refund": {"type": "noul", "instructions": "Is the customer asking for a refund?"}},
|
||||
},
|
||||
upstream_body={
|
||||
"model": "jev-preview",
|
||||
"state": "The replacement part arrived but the wrong size.",
|
||||
"questions": {"is_refund": {"type": "noul", "instructions": "Is the customer asking for a refund?"}},
|
||||
},
|
||||
response=JsonResponse(
|
||||
content_type="application/json",
|
||||
body={
|
||||
"model": "jev-latest",
|
||||
"answers": {"is_refund": {"type": "noul", "noul": 0.31}},
|
||||
"usage": {"input_tokens": 311, "output_tokens": 9},
|
||||
},
|
||||
),
|
||||
expected=ExactExpected(
|
||||
spend=311 * 4.2e-08,
|
||||
input_cost=311 * 4.2e-08,
|
||||
output_cost=0.0,
|
||||
prompt_tokens=311,
|
||||
completion_tokens=9,
|
||||
),
|
||||
)
|
||||
|
||||
# perplexity/pplx-decider-v1-27b
|
||||
PERPLEXITY_PPLX_DECIDER_V1_27B_DECISIONS: Final = CostTrackingTestCase(
|
||||
|
|
@ -514,6 +545,7 @@ CASES: Final[tuple[CostTrackingTestCase, ...]] = (
|
|||
OPENAI_GPT_6_LUNA_SYSTEMONE,
|
||||
TYPESAFE_JEV_LATEST_DECISIONS,
|
||||
TYPESAFE_JEV_LATEST_SYSTEMONE,
|
||||
TYPESAFE_JEV_PREVIEW_ANSWERED_AS_PRICED_VERSION_SYSTEMONE,
|
||||
PERPLEXITY_PPLX_DECIDER_V1_27B_DECISIONS,
|
||||
PERPLEXITY_PPLX_DECIDER_V1_27B_SYSTEMONE,
|
||||
CLOUDFLARE_CLEF_FLASH_DECISIONS,
|
||||
|
|
|
|||
|
|
@ -121,6 +121,12 @@ COST_MAP_ENTRIES: Final[dict[str, dict[str, JsonValue]]] = {
|
|||
"input_cost_per_token": 4.2e-08,
|
||||
"output_cost_per_token": 0.0,
|
||||
},
|
||||
"typesafe/jev-preview": {
|
||||
"litellm_provider": "typesafe",
|
||||
"mode": "evaluation",
|
||||
"input_cost_per_token": 8.4e-08,
|
||||
"output_cost_per_token": 0.0,
|
||||
},
|
||||
"fireworks_ai/accounts/fireworks/routers/rune": {
|
||||
"litellm_provider": "fireworks_ai",
|
||||
"mode": "evaluation",
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ _PROVIDERS: Final = (
|
|||
"databricks-openjev-qwen35-4b",
|
||||
_API_KEY,
|
||||
False,
|
||||
None,
|
||||
"databricks/databricks-openjev-qwen35-4b",
|
||||
),
|
||||
)
|
||||
_PERPLEXITY: Final = _PROVIDERS[0]
|
||||
|
|
@ -576,13 +576,26 @@ def test_upstream_errors_keep_their_status_and_log_an_unbilled_failure(gateway:
|
|||
)
|
||||
|
||||
|
||||
def test_upstream_success_without_answers_is_a_gateway_side_server_error(gateway: Gateway) -> None:
|
||||
@pytest.mark.parametrize(
|
||||
("reply", "field"),
|
||||
(
|
||||
pytest.param({"model": _PERPLEXITY.body_model, "usage": _USAGE}, "answers", id="missing_answers"),
|
||||
pytest.param(
|
||||
{"model": _PERPLEXITY.body_model, "answers": {"defect": {"type": "Request timed out"}}, "usage": _USAGE},
|
||||
"answers.defect",
|
||||
id="answer_type_timeout_text",
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_a_malformed_upstream_success_is_a_server_error_naming_the_field(
|
||||
gateway: Gateway, reply: dict[str, JsonValue], field: str
|
||||
) -> None:
|
||||
with gateway.scenario() as scenario:
|
||||
handle: Final = _register(scenario, {"model": _PERPLEXITY.body_model, "usage": _USAGE})
|
||||
handle: Final = _register(scenario, reply)
|
||||
model: Final = _deployment(scenario, handle, _PERPLEXITY)
|
||||
response: Final = _decide(gateway, model, num_retries=0)
|
||||
assert 500 <= response.status_code < 600, response.text
|
||||
assert "answers" in response.text
|
||||
assert response.status_code == 500, response.text
|
||||
assert field in response.text
|
||||
assert _spend_row(response.headers["x-litellm-call-id"])["status"] == "failure"
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue