fix vertex ai use _get_async_client

This commit is contained in:
Ishaan Jaff 2024-09-10 10:33:19 -07:00
parent b1ecfe065c
commit 1e8cf9f2a6
2 changed files with 19 additions and 41 deletions

View file

@ -19,7 +19,11 @@ import litellm.litellm_core_utils
import litellm.litellm_core_utils.litellm_logging
from litellm import verbose_logger
from litellm.litellm_core_utils.core_helpers import map_finish_reason
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler
from litellm.llms.custom_httpx.http_handler import (
AsyncHTTPHandler,
HTTPHandler,
_get_async_httpx_client,
)
from litellm.llms.prompt_templates.factory import (
convert_url_to_base64,
response_schema_prompt,
@ -1286,15 +1290,10 @@ class VertexLLM(BaseLLM):
) -> Union[ModelResponse, CustomStreamWrapper]:
request_body = await async_transform_request_body(**data) # type: ignore
if client is None or not isinstance(client, AsyncHTTPHandler):
_params = {}
if timeout is not None:
if isinstance(timeout, float) or isinstance(timeout, int):
timeout = httpx.Timeout(timeout)
_params["timeout"] = timeout
client = AsyncHTTPHandler(**_params) # type: ignore
else:
client = client # type: ignore
_async_client_params = {}
if timeout:
_async_client_params["timeout"] = timeout
client = _get_async_httpx_client(params=_async_client_params)
## LOGGING
logging_obj.pre_call(
input=messages,

View file

@ -1,37 +1,16 @@
model_list:
- model_name: openai/*
- model_name: gemini-vision
litellm_params:
model: openai/*
api_key: os.environ/OPENAI_API_KEY
model_info:
id: "good-openai"
- model_name: openai/*
model: vertex_ai/gemini-1.0-pro-vision-001
api_base: https://exampleopenaiendpoint-production.up.railway.app/v1/projects/adroit-crow-413218/locations/us-central1/publishers/google/models/gemini-1.0-pro-vision-001
vertex_project: "adroit-crow-413218"
vertex_location: "us-central1"
vertex_credentials: "/Users/ishaanjaffer/Downloads/adroit-crow-413218-a956eef1a2a8.json"
- model_name: fake-openai-endpoint
litellm_params:
model: openai/*
api_key: os.environ/non-exsitent-env-var
tags: ["bad-model"]
model_info:
id: "test-openai"
litellm_settings:
callbacks: ["otel"]
callback_settings:
otel:
message_logging: False
router_settings:
enable_tag_filtering: True # 👈 Key Chang
model: openai/fake
api_key: fake-key
api_base: https://exampleopenaiendpoint-production.up.railway.app/
general_settings:
master_key: sk-1234
alerting: ["slack"]
spend_report_frequency: "1d"
litellm_settings:
success_callback: ["prometheus"]
failure_callback: ["prometheus"]