From 98da9c73dc4feddce7c9f37c319adf36f7e481ab Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 12 Jul 2025 10:57:18 -0700 Subject: [PATCH] fix bytez validate_environment --- litellm/llms/bytez/chat/transformation.py | 37 ++++++++++------------- litellm/llms/bytez/common_utils.py | 16 ++-------- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/litellm/llms/bytez/chat/transformation.py b/litellm/llms/bytez/chat/transformation.py index 481eb43d82..ccd3c21645 100644 --- a/litellm/llms/bytez/chat/transformation.py +++ b/litellm/llms/bytez/chat/transformation.py @@ -1,34 +1,25 @@ import json import time import traceback -from typing import ( - TYPE_CHECKING, - Any, - List, - Optional, - Union, - Dict, -) +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union import httpx -from litellm.litellm_core_utils.logging_utils import track_llm_api_timing from litellm.litellm_core_utils.exception_mapping_utils import exception_type +from litellm.litellm_core_utils.logging_utils import track_llm_api_timing from litellm.llms.base_llm.chat.transformation import BaseConfig, BaseLLMException -from litellm.utils import CustomStreamWrapper, ModelResponse, Usage -from litellm.types.utils import LlmProviders -from litellm.types.llms.openai import AllMessageValues - from litellm.llms.custom_httpx.http_handler import ( - version, + AsyncHTTPHandler, HTTPHandler, _get_httpx_client, - AsyncHTTPHandler, get_async_httpx_client, + version, ) +from litellm.types.llms.openai import AllMessageValues +from litellm.types.utils import LlmProviders +from litellm.utils import CustomStreamWrapper, ModelResponse, Usage -from ..common_utils import validate_environment, API_BASE, BytezError - +from ..common_utils import API_BASE, BytezError if TYPE_CHECKING: from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj @@ -142,10 +133,14 @@ class BytezChatConfig(BaseConfig): } ) - validate_environment( - messages=messages, - api_key=api_key, - ) + if not messages: + raise Exception( + "kwarg `messages` must be an array of messages that follow the openai chat standard" + ) + + if not api_key: + raise Exception("Missing api_key, make sure you pass in your api key") + return headers diff --git a/litellm/llms/bytez/common_utils.py b/litellm/llms/bytez/common_utils.py index b59d57b2e7..c8a7822502 100644 --- a/litellm/llms/bytez/common_utils.py +++ b/litellm/llms/bytez/common_utils.py @@ -1,4 +1,4 @@ -from typing import Optional, List, Union +from typing import List, Optional, Union import httpx @@ -22,16 +22,4 @@ class BytezError(BaseLLMException): status_code=status_code, message=message, headers=headers, - ) - - -def validate_environment( - api_key: Optional[str] = None, messages: Union[List, None] = None -) -> None: - if not messages: - raise Exception( - "kwarg `messages` must be an array of messages that follow the openai chat standard" - ) - - if not api_key: - raise Exception("Missing api_key, make sure you pass in your api key") + ) \ No newline at end of file