From 933101a3f8ce5c5333adddcf34d8a0084c5d638f Mon Sep 17 00:00:00 2001 From: John HU Date: Thu, 27 Jun 2024 15:26:36 -0700 Subject: [PATCH] Do not resolve project id from creds --- litellm/llms/vertex_httpx.py | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/litellm/llms/vertex_httpx.py b/litellm/llms/vertex_httpx.py index bf650aa4a20..790bb09519b 100644 --- a/litellm/llms/vertex_httpx.py +++ b/litellm/llms/vertex_httpx.py @@ -736,9 +736,6 @@ class VertexLLM(BaseLLM): json_obj, scopes=["https://www.googleapis.com/auth/cloud-platform"], ) - - if project_id is None: - project_id = creds.project_id else: creds, project_id = google_auth.default( quota_project_id=project_id, @@ -747,14 +744,6 @@ class VertexLLM(BaseLLM): creds.refresh(Request()) - if not project_id: - raise ValueError("Could not resolve project_id") - - if not isinstance(project_id, str): - raise TypeError( - f"Expected project_id to be a str but got {type(project_id)}" - ) - return creds, project_id def refresh_auth(self, credentials: Any) -> None: @@ -770,28 +759,17 @@ class VertexLLM(BaseLLM): """ Returns auth token and project id """ - if self.access_token is not None and self.project_id is not None: - return self.access_token, self.project_id - if not self._credentials: - self._credentials, project_id = self.load_auth( + self._credentials, _ = self.load_auth( credentials=credentials, project_id=project_id ) - if not self.project_id: - self.project_id = project_id else: self.refresh_auth(self._credentials) - if not self.project_id: - self.project_id = self._credentials.project_id - - if not self.project_id: - raise ValueError("Could not resolve project_id") - - if not self._credentials or not self._credentials.token: + if not self._credentials.token: raise RuntimeError("Could not resolve API token from the environment") - return self._credentials.token, self.project_id + return self._credentials.token, None def _get_token_and_url( self, @@ -825,7 +803,7 @@ class VertexLLM(BaseLLM): ) ) else: - auth_header, vertex_project = self._ensure_access_token( + auth_header, _ = self._ensure_access_token( credentials=vertex_credentials, project_id=vertex_project ) vertex_location = self.get_vertex_region(vertex_region=vertex_location)