From 7cb49ee509dfe94fae34a57b01819d73d5b8873d Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 16 Jan 2024 16:23:29 -0800 Subject: [PATCH] fix(vertex_ai.py): raise exception if vertex ai missing required dependendencies --- litellm/llms/vertex_ai.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/litellm/llms/vertex_ai.py b/litellm/llms/vertex_ai.py index 77c20d30a5b..57cf6c2a0ec 100644 --- a/litellm/llms/vertex_ai.py +++ b/litellm/llms/vertex_ai.py @@ -216,6 +216,14 @@ def completion( status_code=400, message="vertexai import failed please run `pip install google-cloud-aiplatform`", ) + + if not ( + hasattr(vertexai, "preview") or hasattr(vertexai.preview, "language_models") + ): + raise VertexAIError( + status_code=400, + message="""Upgrade vertex ai. Run `pip install "google-cloud-aiplatform>=1.38"`""", + ) try: from vertexai.preview.language_models import ( ChatModel,