mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
fix(router): undo success_calls on deferred-stream fetch failure; broaden header strip
This commit is contained in:
parent
0f79f103a5
commit
ba98bd0add
1 changed files with 8 additions and 5 deletions
|
|
@ -2870,15 +2870,18 @@ class Router:
|
|||
try:
|
||||
await response.fetch_stream()
|
||||
except Exception as fetch_err:
|
||||
if model_name is not None:
|
||||
self.success_calls[model_name] -= 1
|
||||
_headers = getattr(fetch_err, "headers", None)
|
||||
if isinstance(_headers, dict):
|
||||
_framing_headers = frozenset(
|
||||
{"content-length", "transfer-encoding", "content-encoding", "content-type"}
|
||||
)
|
||||
if _headers is not None and hasattr(_headers, "items"):
|
||||
_strip_headers = frozenset({
|
||||
"content-length", "transfer-encoding", "content-encoding", "content-type",
|
||||
"set-cookie", "cookie", "proxy-authenticate", "proxy-authorization",
|
||||
})
|
||||
setattr(
|
||||
fetch_err,
|
||||
"headers",
|
||||
{k: v for k, v in _headers.items() if k.lower() not in _framing_headers},
|
||||
{k: v for k, v in _headers.items() if k.lower() not in _strip_headers},
|
||||
)
|
||||
raise fetch_err
|
||||
return await self._acompletion_streaming_iterator(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue