mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-25 05:54:53 +00:00
Merge b4488ef892 into 2dfeb80e04
This commit is contained in:
commit
f0df9fc14b
9 changed files with 8 additions and 22 deletions
|
|
@ -189,7 +189,6 @@ def _load_beta_headers_config() -> dict:
|
|||
if _BETA_HEADERS_CONFIG is not None:
|
||||
return _BETA_HEADERS_CONFIG
|
||||
|
||||
# Get the URL from environment or use default
|
||||
from litellm import anthropic_beta_headers_url
|
||||
|
||||
_BETA_HEADERS_CONFIG = get_beta_headers_config(url=anthropic_beta_headers_url)
|
||||
|
|
|
|||
|
|
@ -318,9 +318,7 @@ def _classify_fetch_content(content: bytes, url: str, etag: str | None) -> _Fetc
|
|||
return ModelCostMapReloadUnavailable(reason=f"invalid JSON from {url}: {e}")
|
||||
if not isinstance(parsed, dict):
|
||||
return ModelCostMapReloadUnavailable(reason=f"expected a JSON object from {url}, got {type(parsed).__name__}")
|
||||
model_cost_map: Final = cast( # cast-ok: JSON object keys are strings by definition
|
||||
dict[str, object], parsed
|
||||
)
|
||||
model_cost_map: Final = _BUNDLED_CATALOG_ADAPTER.validate_python(parsed)
|
||||
return ModelCostMapReloaded(model_cost_map=model_cost_map, revision=git_blob_id(content), etag=etag)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2697,7 +2697,7 @@ class Logging(LiteLLMLoggingBaseClass):
|
|||
response: ModelResponse | TextCompletionResponse | ResponsesAPIResponse | InteractionsAPIResponse,
|
||||
) -> ModelResponse | TextCompletionResponse | ResponsesAPIResponse | InteractionsAPIResponse:
|
||||
response_id: Final = self.model_call_details.get("continued_response_id")
|
||||
if not isinstance(response_id, str) or getattr(response, "id", None) == response_id:
|
||||
if not isinstance(response_id, str) or response.id == response_id:
|
||||
return response
|
||||
return response.model_copy(update={"id": response_id})
|
||||
|
||||
|
|
@ -5649,7 +5649,7 @@ def _init_custom_logger_compatible_class(
|
|||
logging_integration: str,
|
||||
internal_usage_cache: DualCache | None,
|
||||
llm_router: object,
|
||||
custom_logger_init_args: dict[str, object] | None = {},
|
||||
custom_logger_init_args: dict[str, object] | None = None,
|
||||
raise_import_errors: bool = False,
|
||||
) -> CustomLogger | None:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -2368,8 +2368,6 @@ class CustomStreamWrapper:
|
|||
return any(get(field) for field in cls._CONTINUATION_DISQUALIFYING_DELTA_FIELDS)
|
||||
|
||||
def _accumulate_streamed_delta(self, delta: object) -> None:
|
||||
# Shared by the sync, async, and non-aiohttp iteration sites so answer
|
||||
# text and the disqualifying-content latch stay in step across all three.
|
||||
get: Final = getattr(delta, "get", None)
|
||||
content: Final = get("content") if callable(get) else None
|
||||
self.response_uptil_now += content if isinstance(content, str) else ""
|
||||
|
|
|
|||
|
|
@ -243,8 +243,7 @@ async def caller_within_model_budget(
|
|||
return "allowed"
|
||||
|
||||
model_max_budget: Final = getattr(user_api_key_auth, "model_max_budget", None)
|
||||
token: Final = getattr(user_api_key_auth, "token", None)
|
||||
if isinstance(model_max_budget, dict) and model_max_budget and token is not None:
|
||||
if isinstance(model_max_budget, dict) and model_max_budget and user_api_key_auth.token is not None:
|
||||
try:
|
||||
await model_max_budget_limiter.is_key_within_model_budget(
|
||||
user_api_key_dict=user_api_key_auth,
|
||||
|
|
@ -299,10 +298,8 @@ async def caller_within_model_budget(
|
|||
)
|
||||
return "denied_for_now"
|
||||
|
||||
end_user_model_max_budget: Final[dict[str, object] | None] = getattr(
|
||||
user_api_key_auth, "end_user_model_max_budget", None
|
||||
)
|
||||
end_user_id: Final[str | None] = getattr(user_api_key_auth, "end_user_id", None)
|
||||
end_user_model_max_budget: Final[dict[str, object] | None] = user_api_key_auth.end_user_model_max_budget
|
||||
end_user_id: Final[str | None] = user_api_key_auth.end_user_id
|
||||
if isinstance(end_user_model_max_budget, dict) and end_user_model_max_budget and end_user_id is not None:
|
||||
try:
|
||||
await model_max_budget_limiter.is_end_user_within_model_budget(
|
||||
|
|
|
|||
|
|
@ -452,9 +452,7 @@ def _converse_request(
|
|||
if not all(_text_only(message) for message in messages):
|
||||
return None
|
||||
try:
|
||||
chat_tools: Final = tuple(
|
||||
chat_tool for tool in tools or () for chat_tool in _as_converse_input(tool)
|
||||
) # comprehension-ok: flattens each tool's translation
|
||||
chat_tools: Final = tuple(chain.from_iterable(_as_converse_input(tool) for tool in tools or ()))
|
||||
return _ConverseRequest.model_validate(
|
||||
litellm.AmazonConverseConfig().transform_request(
|
||||
model=model,
|
||||
|
|
|
|||
|
|
@ -5853,7 +5853,6 @@ def completion(
|
|||
return resolve_timeout(stream_kind=StreamKind.NOT_STREAMED)
|
||||
return resolve_timeout(stream_kind=StreamKind.FAKED if fakes_stream(attempt_params) else StreamKind.LIVE)
|
||||
|
||||
### TIMEOUT LOGIC ###
|
||||
timeout = timeout_for_optional_params(optional_params)
|
||||
logging.record_applied_timeout(timeout)
|
||||
processed_non_default_params: Final = pre_process_non_default_params(
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ def initialize_guardrail(litellm_params: "LitellmParams", guardrail: "Guardrail"
|
|||
additional_provider_specific_params=getattr(litellm_params, "additional_provider_specific_params", {}),
|
||||
unreachable_fallback=getattr(litellm_params, "unreachable_fallback", "fail_closed"),
|
||||
fail_on_error=getattr(litellm_params, "fail_on_error", True),
|
||||
forward_messages_as_sent=getattr(litellm_params, "forward_messages_as_sent", False),
|
||||
forward_messages_as_sent=litellm_params.forward_messages_as_sent,
|
||||
extra_headers=getattr(litellm_params, "extra_headers", None),
|
||||
guardrail_name=guardrail.get("guardrail_name", ""),
|
||||
event_hook=litellm_params.mode,
|
||||
|
|
|
|||
|
|
@ -16067,9 +16067,6 @@ async def _apply_search_filter_to_models(
|
|||
team_public_model_name: Final = (m.get("model_info") or {}).get("team_public_model_name") or ""
|
||||
if search_lower in team_public_model_name.lower():
|
||||
return True
|
||||
# Also match the underlying LiteLLM model name (e.g.
|
||||
# "openrouter/deepseek/deepseek-chat"), so users can find
|
||||
# deployments by typing the provider or the upstream model id.
|
||||
litellm_params: Final[Mapping[str, object]] = m.get("litellm_params") or MappingProxyType({})
|
||||
litellm_model: Final = litellm_params.get("model")
|
||||
return isinstance(litellm_model, str) and search_lower in litellm_model.lower()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue