mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
fix(batch_rate_limiter): wildcard model bypass + fail-open embedded model creds
- _key_requires_batch_model_access_check: check '*' / all-proxy-models before access_group_ids so wildcard keys skip the JSONL download. - _resolve_batch_input_file_fetch_params: wrap embedded-model get_credentials_for_model in try/except HTTPException, mirroring the request-model fallback path, and always decode the file id. Co-authored-by: Yassin Kortam <yassin@berri.ai>
This commit is contained in:
parent
4f9ceddd52
commit
f41ec3e2ab
1 changed files with 17 additions and 14 deletions
|
|
@ -212,14 +212,14 @@ class _PROXY_BatchRateLimiter(CustomLogger):
|
|||
) -> bool:
|
||||
"""True when the key may only call a subset of models (JSONL must be checked)."""
|
||||
models = user_api_key_dict.models or []
|
||||
if user_api_key_dict.access_group_ids:
|
||||
return True
|
||||
if not models:
|
||||
return False
|
||||
if "*" in models:
|
||||
return False
|
||||
if SpecialModelNames.all_proxy_models.value in models:
|
||||
return False
|
||||
if user_api_key_dict.access_group_ids:
|
||||
return True
|
||||
if not models:
|
||||
return False
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -262,16 +262,19 @@ class _PROXY_BatchRateLimiter(CustomLogger):
|
|||
|
||||
model_from_file_id = decode_model_from_file_id(file_id)
|
||||
if model_from_file_id:
|
||||
credentials = get_credentials_for_model(
|
||||
llm_router=llm_router,
|
||||
model_id=model_from_file_id,
|
||||
operation_context="batch input file read (rate limiting)",
|
||||
)
|
||||
fetch_kwargs.update(_extract_file_access_credentials(credentials))
|
||||
fetch_kwargs["model"] = model_from_file_id
|
||||
provider = credentials.get("custom_llm_provider")
|
||||
if provider:
|
||||
fetch_kwargs["custom_llm_provider"] = provider
|
||||
try:
|
||||
credentials = get_credentials_for_model(
|
||||
llm_router=llm_router,
|
||||
model_id=model_from_file_id,
|
||||
operation_context="batch input file read (rate limiting)",
|
||||
)
|
||||
fetch_kwargs.update(_extract_file_access_credentials(credentials))
|
||||
fetch_kwargs["model"] = model_from_file_id
|
||||
provider = credentials.get("custom_llm_provider")
|
||||
if provider:
|
||||
fetch_kwargs["custom_llm_provider"] = provider
|
||||
except HTTPException:
|
||||
pass
|
||||
return get_original_file_id(file_id), fetch_kwargs
|
||||
|
||||
request_model = data.get("model")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue