@@ -104,13 +104,14 @@ def _generate_anthropic(
104
104
"""
105
105
# use Anthropic official SDK references
106
106
# - https://github.com/anthropics/anthropic-sdk-python
107
- service_account_info = json . loads ( base64 . b64decode ( credentials [ "vertex_service_account_key" ]) )
107
+ service_account_key = credentials . get ( "vertex_service_account_key" , "" )
108
108
project_id = credentials ["vertex_project_id" ]
109
109
SCOPES = ["https://www.googleapis.com/auth/cloud-platform" ]
110
110
token = ""
111
111
112
112
# get access token from service account credential
113
- if service_account_info :
113
+ if service_account_key :
114
+ service_account_info = json .loads (base64 .b64decode (service_account_key ))
114
115
credentials = service_account .Credentials .from_service_account_info (service_account_info , scopes = SCOPES )
115
116
request = google .auth .transport .requests .Request ()
116
117
credentials .refresh (request )
@@ -478,10 +479,11 @@ def _generate(
478
479
if stop :
479
480
config_kwargs ["stop_sequences" ] = stop
480
481
481
- service_account_info = json . loads ( base64 . b64decode ( credentials [ "vertex_service_account_key" ]) )
482
+ service_account_key = credentials . get ( "vertex_service_account_key" , "" )
482
483
project_id = credentials ["vertex_project_id" ]
483
484
location = credentials ["vertex_location" ]
484
- if service_account_info :
485
+ if service_account_key :
486
+ service_account_info = json .loads (base64 .b64decode (service_account_key ))
485
487
service_accountSA = service_account .Credentials .from_service_account_info (service_account_info )
486
488
aiplatform .init (credentials = service_accountSA , project = project_id , location = location )
487
489
else :
0 commit comments