fix(main.py): accept vertex service account credentials as json string

allows us to dynamically set vertex ai credentials
This commit is contained in:
Krrish Dholakia 2024-04-15 13:28:59 -07:00
parent c769c3f39b
commit 50081479f9
3 changed files with 71 additions and 15 deletions

View file

@ -1678,6 +1678,11 @@ def completion(
)
if "claude-3" in model:
vertex_credentials = (
optional_params.pop("vertex_credentials", None)
or optional_params.pop("vertex_ai_credentials", None)
or get_secret("VERTEXAI_CREDENTIALS")
)
model_response = vertex_ai_anthropic.completion(
model=model,
messages=messages,
@ -1689,6 +1694,7 @@ def completion(
encoding=encoding,
vertex_location=vertex_ai_location,
vertex_project=vertex_ai_project,
vertex_credentials=vertex_credentials,
logging_obj=logging,
acompletion=acompletion,
)