mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
fix(router.py): support context window fallbacks for pre-call checks
This commit is contained in:
parent
fb1de8b5e0
commit
b2b8375987
2 changed files with 61 additions and 1 deletions
|
@ -2210,6 +2210,18 @@ class Router:
|
|||
):
|
||||
invalid_model_indices.append(idx)
|
||||
|
||||
if len(invalid_model_indices) == len(_returned_deployments):
|
||||
"""
|
||||
- no healthy deployments available b/c context window checks
|
||||
"""
|
||||
raise litellm.ContextWindowExceededError(
|
||||
message="Context Window exceeded for given call",
|
||||
model=model,
|
||||
llm_provider="",
|
||||
response=httpx.Response(
|
||||
status_code=400, request=httpx.Request("GET", "https://example.com")
|
||||
),
|
||||
)
|
||||
if len(invalid_model_indices) > 0:
|
||||
for idx in reversed(invalid_model_indices):
|
||||
_returned_deployments.pop(idx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue