mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
test(cost): assert jina rerank spend at the registry rate
This commit is contained in:
parent
134d1f3899
commit
996ca7c5b2
2 changed files with 17 additions and 3 deletions
|
|
@ -157,9 +157,6 @@ class JinaAIRerankConfig(BaseRerankConfig):
|
|||
billed_units: RerankBilledUnits | None = None,
|
||||
model_info: ModelInfo | None = None,
|
||||
) -> tuple[float, float]:
|
||||
"""
|
||||
Jina AI reranker is priced at $0.000000018 per token.
|
||||
"""
|
||||
if (
|
||||
model_info is None
|
||||
or "input_cost_per_token" not in model_info
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ from litellm.cost_calculator import (
|
|||
response_cost_calculator,
|
||||
)
|
||||
from litellm.types.llms.openai import OpenAIRealtimeStreamList
|
||||
from litellm.types.rerank import RerankResponse
|
||||
from litellm.types.utils import (
|
||||
CacheCreationTokenDetails,
|
||||
ModelInfo,
|
||||
|
|
@ -128,6 +129,22 @@ def test_completion_cost_uses_response_model_for_dynamic_routing(_local_model_co
|
|||
assert cost > 0, "Cost should be calculated using response model"
|
||||
|
||||
|
||||
def test_jina_rerank_bills_total_tokens_at_input_rate_only(_local_model_cost_map):
|
||||
response: Final = RerankResponse(
|
||||
id="rerank-1",
|
||||
results=[{"index": 0, "relevance_score": 0.9}],
|
||||
meta={"billed_units": {"total_tokens": 1000}},
|
||||
)
|
||||
|
||||
cost: Final = completion_cost(
|
||||
completion_response=response,
|
||||
model="jina_ai/jina-reranker-v2-base-multilingual",
|
||||
call_type="rerank",
|
||||
)
|
||||
|
||||
assert cost == pytest.approx(1000 * 5e-08)
|
||||
|
||||
|
||||
def test_cost_calculator_with_response_cost_in_additional_headers():
|
||||
class MockResponse(BaseModel):
|
||||
_hidden_params = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue