Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

refactor(proxy): drop explanatory docstrings from the stream attribution helpers

yucheng0f3556b1bf50
diff --git a/litellm/proxy/common_request_processing.py b/litellm/proxy/common_request_processing.py
index 9a038ca79ba..849211a2dae 100644
--- a/litellm/proxy/common_request_processing.py
+++ b/litellm/proxy/common_request_processing.py
@@ -2576,8 +2576,7 @@ class ProxyBaseLLMRequestProcessing:
)
async def refresh_stream_headers() -> Mapping[str, str]:
- """`custom_headers` rebuilt once the first chunk is buffered, from `self.data` as the
- guardrails left it and for whichever deployment served the stream."""
+ """`custom_headers` rebuilt for whichever deployment served the stream."""
return self._stream_response_headers(
hidden_params=(
get_hidden_params_dict(response)
diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py
index 21e6ed1d24f..4182a864e4c 100644
--- a/litellm/proxy/utils.py
+++ b/litellm/proxy/utils.py
@@ -468,9 +468,6 @@ def _record_raising_guardrail(request_data: Mapping[str, object], callback: obje
class _UpstreamStreamBoundary(Generic[_T]):
- """Remembers the exception the upstream iterator raised, so the wrapper around a
- streaming hook can tell a pass-through failure from one the hook raised itself."""
-
__slots__ = ("_upstream", "failure")
def __init__(self, upstream: AsyncIterable[_T]) -> None:
@@ -2548,14 +2545,6 @@ class ProxyLogging:
hook: _StreamIteratorHook[_T],
request_data: Mapping[str, object],
) -> AsyncGenerator[_T, None]:
- """
- Run `hook` over `response` and yield its chunks. If the hook itself raises,
- enrich an HTTPException's dict detail with the callback's `guardrail_name`
- and `guardrail_mode` and record the callback in `applied_guardrails` before
- re-raising. Failures raised by `response` (the provider stream or an inner
- layer of the async_post_call_streaming_iterator_hook chain) pass through
- untouched, so only the layer that actually raised is attributed.
- """
upstream: Final = _UpstreamStreamBoundary(response)
try:
async for chunk in hook(response=upstream):