From 17b104eb026b71d2588c8d63e11338dbebc98905 Mon Sep 17 00:00:00 2001 From: hawktang Date: Sat, 15 Jun 2024 02:41:46 +0800 Subject: [PATCH 1/2] fix issue to read vertex_credentials --- litellm/llms/vertex_ai_anthropic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/llms/vertex_ai_anthropic.py b/litellm/llms/vertex_ai_anthropic.py index 0652942801c..66be170e376 100644 --- a/litellm/llms/vertex_ai_anthropic.py +++ b/litellm/llms/vertex_ai_anthropic.py @@ -237,7 +237,7 @@ def completion( if vertex_credentials is not None and isinstance(vertex_credentials, str): import google.oauth2.service_account - json_obj = json.loads(vertex_credentials) + json_obj = json.load(open(vertex_credentials)) creds = ( google.oauth2.service_account.Credentials.from_service_account_info( From 4f0dc669df4fa394779aee1fcda7724bed08d6b9 Mon Sep 17 00:00:00 2001 From: hawktang Date: Sat, 15 Jun 2024 14:09:28 +0800 Subject: [PATCH 2/2] add adaptor to fit both json string and json path for vertex_credentials --- litellm/llms/vertex_ai_anthropic.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/litellm/llms/vertex_ai_anthropic.py b/litellm/llms/vertex_ai_anthropic.py index 66be170e376..675dee25f65 100644 --- a/litellm/llms/vertex_ai_anthropic.py +++ b/litellm/llms/vertex_ai_anthropic.py @@ -237,7 +237,10 @@ def completion( if vertex_credentials is not None and isinstance(vertex_credentials, str): import google.oauth2.service_account - json_obj = json.load(open(vertex_credentials)) + try: + json_obj = json.loads(vertex_credentials) + except json.JSONDecodeError: + json_obj = json.load(open(vertex_credentials)) creds = ( google.oauth2.service_account.Credentials.from_service_account_info(