mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
fix: resolve ruff lint errors (#17490)
Fixed 20 of 22 lint errors: - batches/batch_utils.py: Added missing model_name parameter to functions - integrations/custom_guardrail.py: Removed unused Tuple import - llms/custom_httpx/http_handler.py: Removed unused AIOHTTP_NEEDS_CLEANUP_CLOSED import - llms/anthropic/chat/guardrail_translation/handler.py: Prefixed unused variable with underscore - llms/openai/responses/guardrail_translation/handler.py: Removed duplicate BaseModel import, prefixed unused variable - llms/pass_through/guardrail_translation/handler.py: Prefixed unused variables with underscore - proxy/guardrails/guardrail_hooks/generic_guardrail_api/generic_guardrail_api.py: Removed unused List and Tuple imports - proxy/hooks/parallel_request_limiter_v3.py: Removed unused import Remaining 2 errors are PLR0915 (too many statements) which require refactoring.
This commit is contained in:
parent
2627f0d519
commit
2abcc77944
8 changed files with 9 additions and 10 deletions
|
|
@ -15,6 +15,7 @@ from litellm.utils import token_counter
|
|||
async def calculate_batch_cost_and_usage(
|
||||
file_content_dictionary: List[dict],
|
||||
custom_llm_provider: Literal["openai", "azure", "vertex_ai", "hosted_vllm"],
|
||||
model_name: Optional[str] = None,
|
||||
) -> Tuple[float, Usage, List[str]]:
|
||||
"""
|
||||
Calculate the cost and usage of a batch
|
||||
|
|
@ -37,6 +38,7 @@ async def calculate_batch_cost_and_usage(
|
|||
async def _handle_completed_batch(
|
||||
batch: Batch,
|
||||
custom_llm_provider: Literal["openai", "azure", "vertex_ai", "hosted_vllm"],
|
||||
model_name: Optional[str] = None,
|
||||
) -> Tuple[float, Usage, List[str]]:
|
||||
"""Helper function to process a completed batch and handle logging"""
|
||||
# Get batch results
|
||||
|
|
@ -83,6 +85,7 @@ def _get_batch_models_from_file_content(
|
|||
def _batch_cost_calculator(
|
||||
file_content_dictionary: List[dict],
|
||||
custom_llm_provider: Literal["openai", "azure", "vertex_ai", "hosted_vllm"] = "openai",
|
||||
model_name: Optional[str] = None,
|
||||
) -> float:
|
||||
"""
|
||||
Calculate the cost of a batch based on the output file id
|
||||
|
|
@ -251,6 +254,7 @@ def _get_batch_job_cost_from_file_content(
|
|||
def _get_batch_job_total_usage_from_file_content(
|
||||
file_content_dictionary: List[dict],
|
||||
custom_llm_provider: Literal["openai", "azure", "vertex_ai", "hosted_vllm"] = "openai",
|
||||
model_name: Optional[str] = None,
|
||||
) -> Usage:
|
||||
"""
|
||||
Get the tokens of a batch job from the file content
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ from typing import (
|
|||
List,
|
||||
Literal,
|
||||
Optional,
|
||||
Tuple,
|
||||
Type,
|
||||
Union,
|
||||
get_args,
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ class AnthropicMessagesHandler(BaseTranslation):
|
|||
Get the string so far, check the apply guardrail to the string so far, and return the list of responses so far.
|
||||
"""
|
||||
string_so_far = self.get_streaming_string_so_far(responses_so_far)
|
||||
guardrailed_inputs = await guardrail_to_apply.apply_guardrail( # allow rejecting the response, if invalid
|
||||
_guardrailed_inputs = await guardrail_to_apply.apply_guardrail( # allow rejecting the response, if invalid
|
||||
inputs={"texts": [string_so_far]},
|
||||
request_data={},
|
||||
input_type="response",
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ from litellm.constants import (
|
|||
AIOHTTP_CONNECTOR_LIMIT,
|
||||
AIOHTTP_CONNECTOR_LIMIT_PER_HOST,
|
||||
AIOHTTP_KEEPALIVE_TIMEOUT,
|
||||
AIOHTTP_NEEDS_CLEANUP_CLOSED,
|
||||
AIOHTTP_TTL_DNS_CACHE,
|
||||
DEFAULT_SSL_CIPHERS,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, cast
|
|||
|
||||
from openai import BaseModel
|
||||
|
||||
from openai import BaseModel
|
||||
|
||||
from litellm._logging import verbose_proxy_logger
|
||||
from litellm.llms.base_llm.guardrail_translation.base_translation import BaseTranslation
|
||||
from litellm.responses.litellm_completion_transformation.transformation import (
|
||||
|
|
@ -339,7 +337,7 @@ class OpenAIResponsesHandler(BaseTranslation):
|
|||
Process output streaming response by applying guardrails to text content.
|
||||
"""
|
||||
string_so_far = self.get_streaming_string_so_far(responses_so_far)
|
||||
guardrailed_inputs = await guardrail_to_apply.apply_guardrail(
|
||||
_guardrailed_inputs = await guardrail_to_apply.apply_guardrail(
|
||||
inputs={"texts": [string_so_far]},
|
||||
request_data={},
|
||||
input_type="response",
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class PassThroughEndpointHandler(BaseTranslation):
|
|||
return data
|
||||
|
||||
# Apply guardrail (pass-through doesn't modify the text, just checks it)
|
||||
guardrailed_inputs = await guardrail_to_apply.apply_guardrail(
|
||||
_guardrailed_inputs = await guardrail_to_apply.apply_guardrail(
|
||||
inputs={"texts": [text_to_check]},
|
||||
request_data=data,
|
||||
input_type="request",
|
||||
|
|
@ -178,7 +178,7 @@ class PassThroughEndpointHandler(BaseTranslation):
|
|||
request_data["litellm_metadata"] = user_metadata
|
||||
|
||||
# Apply guardrail (pass-through doesn't modify the text, just checks it)
|
||||
guardrailed_inputs = await guardrail_to_apply.apply_guardrail(
|
||||
_guardrailed_inputs = await guardrail_to_apply.apply_guardrail(
|
||||
inputs={"texts": [text_to_check]},
|
||||
request_data=request_data,
|
||||
input_type="response",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
# Thank you users! We ❤️ you! - Krrish & Ishaan
|
||||
|
||||
import os
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Tuple
|
||||
from typing import TYPE_CHECKING, Any, Dict, Literal, Optional
|
||||
|
||||
from litellm._logging import verbose_proxy_logger
|
||||
from litellm.integrations.custom_guardrail import CustomGuardrail
|
||||
|
|
|
|||
|
|
@ -1327,7 +1327,6 @@ class _PROXY_MaxParallelRequestsHandler_v3(CustomLogger):
|
|||
_get_parent_otel_span_from_kwargs,
|
||||
)
|
||||
from litellm.proxy.common_utils.callback_utils import (
|
||||
get_metadata_variable_name_from_kwargs,
|
||||
get_model_group_from_litellm_kwargs,
|
||||
)
|
||||
from litellm.types.caching import RedisPipelineIncrementOperation
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue