mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
Refactor client, timeout, and encoding parameters
This commit is contained in:
parent
b6cba411ba
commit
c9811ba0db
1 changed files with 18 additions and 14 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue