mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-01 07:03:02 +00:00
fix(sdk): type the Decisions retry boundary
This commit is contained in:
parent
b9781d639b
commit
57f6ba5599
1 changed files with 11 additions and 4 deletions
|
|
@ -307,7 +307,7 @@ except (ImportError, AttributeError, TypeError):
|
|||
# Convert to str (if necessary)
|
||||
claude_json_str = json.dumps(json_data)
|
||||
import importlib.metadata
|
||||
from collections.abc import AsyncIterator, Callable, Collection, Iterable, Iterator, Mapping, Sequence, Sized
|
||||
from collections.abc import AsyncIterator, Awaitable, Callable, Collection, Iterable, Iterator, Mapping, Sequence, Sized
|
||||
from typing import TYPE_CHECKING, Any, Final, Literal, Protocol, TypeAlias, TypeVar, cast, runtime_checkable
|
||||
|
||||
from typing_extensions import assert_never
|
||||
|
|
@ -2286,13 +2286,18 @@ def client(original_function):
|
|||
kwargs["num_retries"] = num_retries
|
||||
return litellm.responses_with_retries(*args, **kwargs)
|
||||
elif call_type in (CallTypes.decisions.value, CallTypes.systemone.value):
|
||||
decision_num_retries, decision_kwargs = _get_wrapper_num_retries(kwargs=kwargs, exception=e)
|
||||
decision_num_retries, decision_kwargs = _get_wrapper_num_retries(
|
||||
kwargs=cast("dict[str, object]", kwargs), # cast-ok: decorator kwargs always have string keys
|
||||
exception=e,
|
||||
)
|
||||
if (
|
||||
decision_num_retries
|
||||
and not _is_litellm_router_call(decision_kwargs, is_async=False)
|
||||
and isinstance(e, openai.APIError)
|
||||
):
|
||||
return litellm.completion_with_retries(
|
||||
return cast( # cast-ok: legacy retry helper forwards arbitrary SDK arguments
|
||||
"Callable[..., object]", litellm.completion_with_retries
|
||||
)(
|
||||
*args,
|
||||
**{**decision_kwargs, "num_retries": decision_num_retries, "original_function": wrapper},
|
||||
)
|
||||
|
|
@ -2625,7 +2630,9 @@ def client(original_function):
|
|||
and not _is_litellm_router_call(kwargs, is_async=True)
|
||||
and isinstance(e, openai.APIError)
|
||||
):
|
||||
return await litellm.acompletion_with_retries(
|
||||
return await cast( # cast-ok: legacy retry helper forwards arbitrary SDK arguments
|
||||
"Callable[..., Awaitable[object]]", litellm.acompletion_with_retries
|
||||
)(
|
||||
*args,
|
||||
**{
|
||||
**kwargs,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue