mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-22 00:31:44 +00:00
fix(proxy): type anthropic pre-call hook inputs
This commit is contained in:
parent
19a8e3fdd6
commit
20adad495c
1 changed files with 19 additions and 3 deletions
|
|
@ -8,7 +8,17 @@
|
|||
import asyncio
|
||||
import contextvars
|
||||
from functools import partial
|
||||
from typing import Any, AsyncIterator, Coroutine, Dict, List, Optional, Union, cast
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
AsyncIterator,
|
||||
Coroutine,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Union,
|
||||
cast,
|
||||
)
|
||||
|
||||
import litellm
|
||||
from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj
|
||||
|
|
@ -31,6 +41,10 @@ from ..responses_adapters.handler import LiteLLMMessagesToResponsesAPIHandler
|
|||
from .interceptors import get_messages_interceptors
|
||||
from .utils import AnthropicMessagesRequestUtils, mock_response
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from litellm.caching.caching import DualCache
|
||||
from litellm.proxy._types import UserAPIKeyAuth
|
||||
|
||||
# Providers that are routed directly to the OpenAI Responses API instead of
|
||||
# going through chat/completions.
|
||||
_RESPONSES_API_PROVIDERS = frozenset({"openai"})
|
||||
|
|
@ -134,8 +148,10 @@ async def _execute_pre_request_hooks(
|
|||
# Keep the experimental Messages path in parity with the proxy
|
||||
# pre-call hook contract used by the standard /v1/messages path.
|
||||
modified_kwargs = await callback.async_pre_call_hook(
|
||||
user_api_key_dict=request_kwargs.get("user_api_key_dict"),
|
||||
cache=request_kwargs.get("cache"),
|
||||
user_api_key_dict=cast(
|
||||
"UserAPIKeyAuth", request_kwargs.get("user_api_key_dict")
|
||||
),
|
||||
cache=cast("DualCache", request_kwargs.get("cache")),
|
||||
data=request_kwargs,
|
||||
call_type="anthropic_messages",
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue