mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-17 09:34:48 +00:00
fix(realtime): bill a translation rate the deployment omits from the session model
This commit is contained in:
parent
8743521f73
commit
f30ea4c7f8
2 changed files with 26 additions and 7 deletions
|
|
@ -3758,13 +3758,8 @@ def handle_realtime_translation_cost_calculation(
|
|||
input_seconds, output_seconds = _translation_session_seconds(results)
|
||||
if input_seconds <= 0 and output_seconds <= 0:
|
||||
return 0.0
|
||||
deployment_rates: Final = _translation_per_second_rates(
|
||||
(*deployment_pricing_models, litellm_model_name), custom_llm_provider
|
||||
)
|
||||
input_rate, output_rate = (
|
||||
deployment_rates
|
||||
if any(rate is not None for rate in deployment_rates)
|
||||
else _translation_per_second_rates((session_model,), custom_llm_provider)
|
||||
input_rate, output_rate = _translation_per_second_rates(
|
||||
(*deployment_pricing_models, litellm_model_name, session_model), custom_llm_provider
|
||||
)
|
||||
return input_seconds * (input_rate or 0.0) + output_seconds * (output_rate or 0.0)
|
||||
|
||||
|
|
|
|||
|
|
@ -10332,6 +10332,30 @@ def test_realtime_translation_deployment_per_second_rates_fall_back_to_public_ra
|
|||
) == pytest.approx(60 * 0.001 + (60 * public_input_rate if bills_public_input_rate else 0.0))
|
||||
|
||||
|
||||
def test_realtime_translation_custom_deployment_with_one_rate_bills_the_session_model_for_the_other(
|
||||
_local_model_cost_map: None,
|
||||
) -> None:
|
||||
litellm.Router(
|
||||
model_list=[
|
||||
{
|
||||
"model_name": "translate",
|
||||
"litellm_params": {
|
||||
"model": "openai/my-translator",
|
||||
"api_key": "sk-test",
|
||||
"output_cost_per_second": 0.001,
|
||||
},
|
||||
"model_info": {"id": "custom-translate-output-priced"},
|
||||
}
|
||||
]
|
||||
)
|
||||
public_input_rate: Final = litellm.model_cost["gpt-realtime-translate"]["input_cost_per_second"]
|
||||
|
||||
assert public_input_rate > 0
|
||||
assert _translation_session_cost(
|
||||
"custom-translate-output-priced", model="my-translator"
|
||||
) == pytest.approx(60 * 0.001 + 60 * public_input_rate)
|
||||
|
||||
|
||||
def test_realtime_translation_rate_ignores_a_session_model_the_deployment_does_not_run(
|
||||
_local_model_cost_map: None,
|
||||
) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue