mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
Fix code qa and mypy lint issues
This commit is contained in:
parent
4088f2b6da
commit
8da3efdfbe
5 changed files with 19 additions and 6 deletions
|
|
@ -28,6 +28,7 @@ from litellm.integrations.websearch_interception.transformation import (
|
|||
from litellm.types.integrations.websearch_interception import (
|
||||
WebSearchInterceptionConfig,
|
||||
)
|
||||
from litellm.types.llms.openai import AllMessageValues
|
||||
from litellm.types.utils import LlmProviders
|
||||
from litellm.utils import ProviderConfigManager
|
||||
|
||||
|
|
@ -138,7 +139,7 @@ class WebSearchInterceptionLogger(CustomLogger):
|
|||
get_last_user_message,
|
||||
)
|
||||
|
||||
query = get_last_user_message(messages)
|
||||
query = get_last_user_message(cast(List[AllMessageValues], messages))
|
||||
if not query:
|
||||
return None
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
import asyncio
|
||||
import contextvars
|
||||
from functools import partial
|
||||
from typing import Any, AsyncIterator, Coroutine, Dict, List, Optional, Union
|
||||
from typing import Any, AsyncIterator, Coroutine, Dict, List, Optional, Union, cast
|
||||
|
||||
import litellm
|
||||
from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj
|
||||
|
|
@ -151,13 +151,14 @@ async def _try_websearch_short_circuit(
|
|||
custom_llm_provider=custom_llm_provider,
|
||||
)
|
||||
if response is not None:
|
||||
anthropic_response = cast(AnthropicMessagesResponse, response)
|
||||
if stream:
|
||||
from litellm.llms.anthropic.experimental_pass_through.messages.fake_stream_iterator import (
|
||||
FakeAnthropicMessagesStreamIterator,
|
||||
)
|
||||
|
||||
return FakeAnthropicMessagesStreamIterator(response)
|
||||
return response
|
||||
return FakeAnthropicMessagesStreamIterator(anthropic_response)
|
||||
return anthropic_response
|
||||
|
||||
return None
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from typing import (
|
|||
Any,
|
||||
AsyncIterator,
|
||||
Coroutine,
|
||||
Dict,
|
||||
Iterator,
|
||||
List,
|
||||
Literal,
|
||||
|
|
@ -805,7 +806,7 @@ class OpenAIChatCompletionStreamingHandler(BaseModelResponseIterator):
|
|||
choices = chunk.get("choices", [])
|
||||
choices = self._map_reasoning_to_reasoning_content(choices)
|
||||
|
||||
kwargs = {
|
||||
kwargs: Dict[str, Any] = {
|
||||
"id": chunk.get("id"),
|
||||
"object": "chat.completion.chunk",
|
||||
"created": chunk.get("created"),
|
||||
|
|
|
|||
|
|
@ -560,7 +560,8 @@ def _get_deployment_default_limit(model_name: str, field: str) -> Optional[int]:
|
|||
raw = deployment.get("litellm_params", {}).get(field)
|
||||
if raw is not None:
|
||||
try:
|
||||
limits.append(int(raw))
|
||||
if isinstance(raw, (int, float, str, bytes, bytearray)):
|
||||
limits.append(int(raw))
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
return min(limits) if limits else None
|
||||
|
|
|
|||
|
|
@ -478,6 +478,15 @@ class _PROXY_MaxParallelRequestsHandler(CustomLogger):
|
|||
kwargs["litellm_params"]["metadata"].get("user_api_key_metadata", {})
|
||||
or {}
|
||||
)
|
||||
user_api_key_team_metadata = kwargs["litellm_params"]["metadata"].get(
|
||||
"user_api_key_team_metadata", None
|
||||
)
|
||||
user_api_key_dict = UserAPIKeyAuth(
|
||||
api_key=user_api_key,
|
||||
metadata=user_api_key_metadata,
|
||||
model_max_budget=user_api_key_model_max_budget,
|
||||
team_metadata=user_api_key_team_metadata,
|
||||
)
|
||||
|
||||
# ------------
|
||||
# Setup values
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue