Skip to content

Commit

Permalink
leave comment for vertex ai model support
Browse files Browse the repository at this point in the history
  • Loading branch information
cyyeh committed Oct 2, 2024
1 parent 85535e9 commit 4111a74
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion wren-ai-service/src/providers/llm/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,17 @@ def __init__(
)

# check if the model is actually Vertex AI model
# currently we support Vertex AI through openai api compatible way
# in the near future, we might use litellm instead, so we can more easily support different kinds of llm providers
# this is workaround as of now
self._vertexai_creds = None
if model.startswith("google/"):
self._vertexai_creds, _ = google.auth.default(
scopes=["https://www.googleapis.com/auth/cloud-platform"]
)

def __getattr__(self, name: str) -> Any:
# dealing with auto-refreshing expired credential
# dealing with auto-refreshing expired credential for Vertex AI model
# https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/call-vertex-using-openai-library#refresh_your_credentials
if self._vertexai_creds and not self._vertexai_creds.valid:
auth_req = google.auth.transport.requests.Request()
Expand Down

0 comments on commit 4111a74

Please sign in to comment.