mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
fix(bedrock): strip [1m]/[200k] context window suffixes before cost lookup
This commit is contained in:
parent
e4442a4d98
commit
440c3387df
1 changed files with 11 additions and 5 deletions
|
|
@ -432,12 +432,16 @@ def strip_bedrock_routing_prefix(model: str) -> str:
|
|||
|
||||
|
||||
def strip_bedrock_throughput_suffix(model: str) -> str:
|
||||
"""Strip throughput tier suffixes from Bedrock model names."""
|
||||
"""Strip throughput tier suffixes and context window suffixes from Bedrock model names."""
|
||||
import re
|
||||
|
||||
# Pattern matches model:version:throughput where throughput is like 51k, 18k, etc.
|
||||
# Keep the model:version part, strip the :throughput suffix
|
||||
return re.sub(r"(:\d+):\d+k$", r"\1", model)
|
||||
model = re.sub(r"(:\d+):\d+k$", r"\1", model)
|
||||
# Strip context window suffixes like [1m], [200k], etc.
|
||||
# e.g. "us.anthropic.claude-opus-4-6-v1[1m]" -> "us.anthropic.claude-opus-4-6-v1"
|
||||
model = re.sub(r"\[\w+\]$", "", model)
|
||||
return model
|
||||
|
||||
|
||||
def get_bedrock_base_model(model: str) -> str:
|
||||
|
|
@ -1062,9 +1066,11 @@ class CommonBatchFilesUtils:
|
|||
|
||||
return (
|
||||
dict(prepped.headers),
|
||||
request_data.encode("utf-8")
|
||||
if isinstance(request_data, str)
|
||||
else request_data,
|
||||
(
|
||||
request_data.encode("utf-8")
|
||||
if isinstance(request_data, str)
|
||||
else request_data
|
||||
),
|
||||
)
|
||||
|
||||
def generate_unique_job_name(self, model: str, prefix: str = "litellm") -> str:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue