diff --git a/litellm/llms/base_llm/files/transformation.py b/litellm/llms/base_llm/files/transformation.py index 5ecf033fb2c..ec0b28a63ad 100644 --- a/litellm/llms/base_llm/files/transformation.py +++ b/litellm/llms/base_llm/files/transformation.py @@ -6,7 +6,6 @@ import httpx from openai.types.file_deleted import FileDeleted from litellm.files.types import FileContentStreamingResult -from litellm.proxy._types import UserAPIKeyAuth from litellm.types.files import TwoStepFileUploadConfig from litellm.types.llms.openai import ( AllMessageValues, @@ -23,16 +22,19 @@ from ..chat.transformation import BaseConfig if TYPE_CHECKING: from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj from litellm.litellm_core_utils.tokenizer import Encoding as Tokenizer + from litellm.proxy._types import UserAPIKeyAuth as _UserAPIKeyAuth from litellm.router import Router as _Router from litellm.types.llms.openai import HttpxBinaryResponseContent LiteLLMLoggingObj = _LiteLLMLoggingObj Span = Any Router = _Router + UserAPIKeyAuth = _UserAPIKeyAuth else: LiteLLMLoggingObj = Any Span = Any Router = Any + UserAPIKeyAuth = Any class BaseFileUploadStream(ABC): diff --git a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/typesafe_passthrough_logging_handler.py b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/typesafe_passthrough_logging_handler.py index 03ec559b83d..0fa2bfff218 100644 --- a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/typesafe_passthrough_logging_handler.py +++ b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/typesafe_passthrough_logging_handler.py @@ -1,6 +1,6 @@ from collections.abc import Mapping from datetime import datetime -from typing import Final +from typing import TYPE_CHECKING, Final import httpx from pydantic import BaseModel, TypeAdapter, ValidationError @@ -11,9 +11,11 @@ from litellm.litellm_core_utils.litellm_logging import ( get_standard_logging_object_payload, # pyright: ignore[reportUnknownVariableType] # legacy helper has an untyped signature ) from litellm.llms.laya.common_utils import laya_response_model -from litellm.proxy._types import PassThroughEndpointLoggingTypedDict from litellm.types.utils import ModelResponse, StandardPassThroughResponseObject, Usage +if TYPE_CHECKING: + from litellm.proxy._types import PassThroughEndpointLoggingTypedDict + class _TypeSafeUsage(BaseModel): input_tokens: int = 0 @@ -68,7 +70,7 @@ class TypeSafePassthroughLoggingHandler: request_body: Mapping[str, object], custom_llm_provider: str, **kwargs: object, - ) -> PassThroughEndpointLoggingTypedDict: + ) -> "PassThroughEndpointLoggingTypedDict": response: Final = _parse_typesafe_response(response_body) request_model_value: Final = request_body.get("model") request_model: Final = request_model_value if isinstance(request_model_value, str) else None diff --git a/litellm/responses/litellm_completion_transformation/session_handler.py b/litellm/responses/litellm_completion_transformation/session_handler.py index 1d6a47d6365..e6f4b364815 100644 --- a/litellm/responses/litellm_completion_transformation/session_handler.py +++ b/litellm/responses/litellm_completion_transformation/session_handler.py @@ -5,7 +5,6 @@ from typing import TYPE_CHECKING, Any, Final, cast import litellm from litellm._logging import verbose_proxy_logger from litellm.constants import REDACTED_BY_LITELLM, REDACTED_TOOL_CALL_ARGUMENTS_PLACEHOLDER -from litellm.proxy._types import SpendLogsMetadata, SpendLogsPayload from litellm.proxy.spend_tracking.cold_storage_handler import ColdStorageHandler from litellm.responses.utils import ResponsesAPIRequestUtils from litellm.types.llms.openai import ( @@ -17,6 +16,7 @@ from litellm.types.llms.openai import ( from litellm.types.utils import ChatCompletionMessageToolCall, Message, ModelResponse if TYPE_CHECKING: + from litellm.proxy._types import SpendLogsMetadata, SpendLogsPayload from litellm.responses.litellm_completion_transformation.transformation import ( ChatCompletionSession, ) @@ -89,7 +89,7 @@ class ResponsesSessionHandler: @staticmethod async def extend_chat_completion_message_with_spend_log_payload( - spend_log: SpendLogsPayload, + spend_log: "SpendLogsPayload", chat_completion_message_history: list[ AllMessageValues | GenericChatCompletionMessage @@ -161,7 +161,7 @@ class ResponsesSessionHandler: @staticmethod async def get_proxy_server_request_from_spend_log( - spend_log: SpendLogsPayload, + spend_log: "SpendLogsPayload", ) -> dict | None: """ Get the parsed proxy server request from the spend log @@ -194,7 +194,7 @@ class ResponsesSessionHandler: @staticmethod def _get_cold_storage_object_key_from_spend_log( - spend_log: SpendLogsPayload, + spend_log: "SpendLogsPayload", ) -> str | None: """ Extract the cold storage object key from spend log metadata. @@ -265,7 +265,7 @@ class ResponsesSessionHandler: @staticmethod async def get_all_spend_logs_for_previous_response_id( previous_response_id: str, - ) -> list[SpendLogsPayload]: + ) -> "list[SpendLogsPayload]": """ Get all spend logs for a previous response id