mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-14 09:03:16 +00:00
fix: bill regional uplift multipliers float() accepts, bytes included
Some checks failed
LiteLLM Rust DB / db-queries (push) Waiting to run
LiteLLM Rust / rust-lint (push) Waiting to run
LiteLLM Rust / rust-test (push) Waiting to run
LiteLLM Rust / rust-wheel (push) Waiting to run
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled
Terraform Modules / fmt, validate, test (gcp) (push) Has been cancelled
Some checks failed
LiteLLM Rust DB / db-queries (push) Waiting to run
LiteLLM Rust / rust-lint (push) Waiting to run
LiteLLM Rust / rust-test (push) Waiting to run
LiteLLM Rust / rust-wheel (push) Waiting to run
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled
Terraform Modules / fmt, validate, test (gcp) (push) Has been cancelled
This commit is contained in:
parent
b471e57be8
commit
114090d208
2 changed files with 11 additions and 3 deletions
|
|
@ -6,10 +6,10 @@ from collections.abc import Mapping, Sequence
|
|||
from dataclasses import dataclass, field, replace
|
||||
from datetime import datetime, timezone, tzinfo
|
||||
from types import MappingProxyType
|
||||
from typing import Final, Literal, Protocol, SupportsFloat, TypedDict, cast
|
||||
from typing import Final, Literal, Protocol, SupportsFloat, SupportsIndex, TypedDict, cast
|
||||
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
||||
|
||||
from typing_extensions import ReadOnly
|
||||
from typing_extensions import Buffer, ReadOnly
|
||||
|
||||
import litellm
|
||||
from litellm._internal_context import current_billing_time
|
||||
|
|
@ -1427,7 +1427,7 @@ def get_regional_uplift_multiplier(model_info: ModelInfo, data_residency: str |
|
|||
multiplier: Final = model_info.get(f"regional_processing_uplift_multiplier_{residency}")
|
||||
if multiplier is None:
|
||||
return 1.0
|
||||
if not isinstance(multiplier, (str, SupportsFloat)):
|
||||
if not isinstance(multiplier, (str, Buffer, SupportsFloat, SupportsIndex)):
|
||||
verbose_logger.error(
|
||||
"Invalid regional_processing_uplift_multiplier_%s for model; defaulting to 1.0",
|
||||
residency,
|
||||
|
|
|
|||
|
|
@ -2790,6 +2790,14 @@ def test_regional_uplift_reads_the_multiplier_named_by_each_residency(model_info
|
|||
assert get_regional_uplift_multiplier(model_info, data_residency) == 1.25
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"model_info",
|
||||
[{"regional_processing_uplift_multiplier_us": value} for value in (1.25, "1.25", b"1.25", bytearray(b"1.25"))],
|
||||
)
|
||||
def test_regional_uplift_accepts_every_value_float_converts(model_info: ModelInfo):
|
||||
assert get_regional_uplift_multiplier(model_info, "us") == 1.25
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"model_info, data_residency",
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue