add adaptor to fit both json string and json path for vertex_credentials

This commit is contained in:
hawktang 2024-06-15 14:09:28 +08:00 committed by GitHub
parent 17b104eb02
commit 4f0dc669df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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(