litellm/tests/unit/proxy/engine/test_inference.py
moe-berri 6fd9334751
feat(lens): analyze agent activity with a separate worker (#43889)
* feat(tracing): bring current ingestion prerequisite onto main

Port the prerequisite implementation from BerriAI/litellm#43915 at 5aacd57455 so Lens does not depend on the retired tracing stack.

* feat(lens): add trace analysis and standalone worker

* fix(lens): clarify review limits and finalize main integration

* fix(lens): simplify worker setup and show the next check

* fix(lens): simplify analyzer setup and resolve integration failures

* fix(lens): preserve durations and evidence from later trace reads

* fix(lens): trust server context for internal analysis exclusion

* fix(lens): pin reviewed analyzer image and verify request inclusion

* test(lens): select time units before entering custom duration

* test(lens): allow the standalone analyzer lifetime HTTP client

* test(lens): run analyzer tests in active proxy coverage shard
2026-09-30 22:42:09 +00:00

19 lines
714 B
Python

from typing import Final
import pytest
from litellm.proxy.engine.inference import Deployment, DeploymentParams, completion_charge, quote
from litellm.types.utils import ModelResponse
def test_custom_priced_model_charges_reported_tokens() -> None:
deployment: Final = Deployment(
litellm_params=DeploymentParams(
model="openai/engine-test", input_cost_per_token=0.001, output_cost_per_token=0.002
)
)
response: Final = ModelResponse(
model="engine-test", usage={"prompt_tokens": 20, "completion_tokens": 10, "total_tokens": 30}
)
assert completion_charge((deployment,), response, 10) == pytest.approx(0.04)
assert quote((deployment,), "hello") > 0.04