mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 19:54:13 +00:00
Load google ADC before init AnthropicVertex
This commit is contained in:
parent
741a18a040
commit
8e63e49348
1 changed files with 7 additions and 5 deletions
|
@ -123,7 +123,7 @@ class VertexAIAnthropicConfig:
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
- Run client init
|
- Run client init
|
||||||
- Support async completion, streaming
|
- Support async completion, streaming
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -236,17 +236,19 @@ def completion(
|
||||||
if client is None:
|
if client is None:
|
||||||
if vertex_credentials is not None and isinstance(vertex_credentials, str):
|
if vertex_credentials is not None and isinstance(vertex_credentials, str):
|
||||||
import google.oauth2.service_account
|
import google.oauth2.service_account
|
||||||
|
|
||||||
json_obj = json.loads(vertex_credentials)
|
|
||||||
|
|
||||||
creds = (
|
creds = (
|
||||||
google.oauth2.service_account.Credentials.from_service_account_info(
|
google.oauth2.service_account.Credentials.from_service_account_info(
|
||||||
json_obj,
|
json.loads(vertex_credentials),
|
||||||
scopes=["https://www.googleapis.com/auth/cloud-platform"],
|
scopes=["https://www.googleapis.com/auth/cloud-platform"],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
### CHECK IF ACCESS
|
### CHECK IF ACCESS
|
||||||
access_token = refresh_auth(credentials=creds)
|
access_token = refresh_auth(credentials=creds)
|
||||||
|
else:
|
||||||
|
import google.auth
|
||||||
|
creds, _ = google.auth.default()
|
||||||
|
### CHECK IF ACCESS
|
||||||
|
access_token = refresh_auth(credentials=creds)
|
||||||
|
|
||||||
vertex_ai_client = AnthropicVertex(
|
vertex_ai_client = AnthropicVertex(
|
||||||
project_id=vertex_project,
|
project_id=vertex_project,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue