mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-11 08:38:24 +00:00
refactor: read include_cost_in_streaming_usage directly, type MaskedHTTPStatusError init, drop unused encrypted reasoning check (#50617)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
bece938ccc
commit
82ef50bacb
3 changed files with 4 additions and 10 deletions
|
|
@ -123,7 +123,7 @@ def proxy_request_headers(container: Mapping[str, object] | None) -> Mapping[str
|
|||
|
||||
def stream_cost_injection_requested(request_headers: Mapping[str, object] | None) -> bool:
|
||||
"""The global include_cost_in_streaming_usage flag or the per-request header asks for usage.cost on streams."""
|
||||
if bool(getattr(litellm, "include_cost_in_streaming_usage", False)):
|
||||
if litellm.include_cost_in_streaming_usage:
|
||||
return True
|
||||
if not request_headers:
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -282,14 +282,6 @@ def anthropic_content_lists(messages: Sequence[object]) -> Iterator[object]:
|
|||
)
|
||||
|
||||
|
||||
def _content_carries_encrypted_reasoning(content: object) -> bool:
|
||||
return any(is_encrypted_reasoning_block(block) for block in _object_sequence(content))
|
||||
|
||||
|
||||
def messages_carry_encrypted_reasoning(messages: Sequence[object]) -> bool:
|
||||
return any(_content_carries_encrypted_reasoning(content) for content in anthropic_content_lists(messages))
|
||||
|
||||
|
||||
def _strip_encrypted_reasoning_from_blocks(
|
||||
content: object,
|
||||
*,
|
||||
|
|
|
|||
|
|
@ -663,7 +663,9 @@ class HTTPResponseLimitError(ValueError):
|
|||
|
||||
|
||||
class MaskedHTTPStatusError(httpx.HTTPStatusError):
|
||||
def __init__(self, original_error: httpx.HTTPStatusError, message: str | None = None, text: str | None = None):
|
||||
def __init__(
|
||||
self, original_error: httpx.HTTPStatusError, message: str | None = None, text: str | None = None
|
||||
) -> None:
|
||||
# Create a new error with the masked URL
|
||||
masked_url: Final = mask_sensitive_info(str(original_error.request.url))
|
||||
# Mask the original exception message too (it contains the full URL)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue