From 3949e850af3346b641c1403963e844456e1567c4 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Tue, 26 Sep 2023 10:25:11 -0700 Subject: [PATCH] add palm exception mapping --- litellm/utils.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/litellm/utils.py b/litellm/utils.py index 5016eb4db0..96217f4162 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -2282,6 +2282,24 @@ def exception_type( model=model, llm_provider="vertex_ai" ) + elif custom_llm_provider == "palm": + if "503 Getting metadata" in error_str: + # auth errors look like this + # 503 Getting metadata from plugin failed with error: Reauthentication is needed. Please run `gcloud auth application-default login` to reauthenticate. + exception_mapping_worked = True + raise InvalidRequestError( + message=f"PalmException - Invalid api key", + model=model, + llm_provider="palm" + ) + if "400 Request payload size exceeds" in error_str: + exception_mapping_worked = True + raise ContextWindowExceededError( + message=f"PalmException - {error_str}", + model=model, + llm_provider="palm", + ) + # Dailed: Error occurred: 400 Request payload size exceeds the limit: 20000 bytes elif custom_llm_provider == "cohere": # Cohere if ( "invalid api token" in error_str