mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-02 07:13:02 +00:00
fix(passthrough): type stash/request dicts to stay inside basedpyright ceiling
This commit is contained in:
parent
87823fbada
commit
fcb2a96dda
1 changed files with 17 additions and 12 deletions
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Any, Final
|
||||
from typing import Any, Final, cast
|
||||
|
||||
import litellm
|
||||
from litellm.litellm_core_utils.url_utils import join_api_base
|
||||
|
|
@ -95,17 +95,22 @@ class OpenAILikeAnthropicMessagesConfig(AnthropicMessagesConfig):
|
|||
model the cost map does not know (see #40890). Pop them before the
|
||||
base transform so no drop warning fires, restore afterwards.
|
||||
"""
|
||||
stashed: Final = {
|
||||
_key: anthropic_messages_optional_request_params.pop(_key)
|
||||
for _key in ("thinking", "output_config", "temperature")
|
||||
if _key in anthropic_messages_optional_request_params
|
||||
}
|
||||
request: Final = super().transform_anthropic_messages_request(
|
||||
model=model,
|
||||
messages=messages,
|
||||
anthropic_messages_optional_request_params=anthropic_messages_optional_request_params,
|
||||
litellm_params=litellm_params,
|
||||
headers=headers,
|
||||
params: Final[dict[str, object]] = cast(
|
||||
dict[str, object], anthropic_messages_optional_request_params
|
||||
)
|
||||
stashed: Final[dict[str, object]] = {}
|
||||
for _key in ("thinking", "output_config", "temperature"):
|
||||
if _key in params:
|
||||
stashed[_key] = params.pop(_key)
|
||||
request: Final[dict[str, object]] = cast(
|
||||
dict[str, object],
|
||||
super().transform_anthropic_messages_request( # pyright: ignore[reportUnknownMemberType] # base returns unparameterized dict
|
||||
model=model,
|
||||
messages=messages,
|
||||
anthropic_messages_optional_request_params=params,
|
||||
litellm_params=litellm_params,
|
||||
headers=headers,
|
||||
),
|
||||
)
|
||||
if self.supports_cache_control_ttl():
|
||||
request.update(stashed)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue