diff --git a/litellm/llms/vertex_ai/vertex_gemma_models/transformation.py b/litellm/llms/vertex_ai/vertex_gemma_models/transformation.py index b0c7c4ead04..23dbabeaac7 100644 --- a/litellm/llms/vertex_ai/vertex_gemma_models/transformation.py +++ b/litellm/llms/vertex_ai/vertex_gemma_models/transformation.py @@ -189,9 +189,9 @@ class VertexGemmaConfig(OpenAIGPTConfig): logging_obj: Any, optional_params: dict, litellm_params: dict, - client= Optional[Any], - timeout: Optional[Union[float, httpx.Timeout]], - encoding: Any, + client= Optional[Any] = None, + timeout: Optional[Union[float, httpx.Timeout]]= None, + encoding: Any= None, ): """Synchronous completion request""" from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler @@ -230,14 +230,13 @@ class VertexGemmaConfig(OpenAIGPTConfig): http_handler = HTTPHandler(concurrent_limit=1) elif isinstance(client, httpx.Client): http_handler = HTTPHandler(client=client) - else: + elif isinstance(client, HTTPHandler): http_handler = client - response = http_handler.post( - url=api_base, - headers=headers, - json=request_data, - timeout=timeout, - ) + else: + raise BaseLLMException( + status_code=400, + message=f"Invalid sync client type: {type(client)}. Expected HTTPHandler or httpx.Client.", + ) if response.status_code != 200: raise BaseLLMException( @@ -287,9 +286,9 @@ class VertexGemmaConfig(OpenAIGPTConfig): logging_obj: Any, optional_params: dict, litellm_params: dict, - client: Optional[Any], - timeout: Optional[Union[float, httpx.Timeout]], - encoding: Any, + client: Optional[Any]= None, + timeout: Optional[Union[float, httpx.Timeout]]= None, + encoding: Any= None, ): """Asynchronous completion request""" from litellm.llms.custom_httpx.http_handler import ( @@ -333,8 +332,13 @@ class VertexGemmaConfig(OpenAIGPTConfig): http_handler = get_async_httpx_client( llm_provider=LlmProviders.VERTEX_AI, ) - else: + elif isinstance(client, (httpx.AsyncClient, AsyncHTTPHandler)): http_handler = client + else: + raise BaseLLMException( + status_code=400, + message=f"Invalid async client type: {type(client)}. Expected AsyncHTTPHandler or httpx.AsyncClient.", + ) response = await http_handler.post( url=api_base,