From 69f0a75882ba847126fdc2e95a67b6c62fc6e401 Mon Sep 17 00:00:00 2001 From: Pablo Elgueta Date: Tue, 16 Sep 2025 10:28:22 -0300 Subject: [PATCH 1/2] feat: add support for global location in Vertex AI base URL - Update _get_base_url method to handle 'global' location case - Use 'aiplatform.googleapis.com' for global locations - Use '{location}-aiplatform.googleapis.com' for regional locations - Maintains backward compatibility with existing regional endpoints --- src/pipecat/services/google/llm_vertex.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/pipecat/services/google/llm_vertex.py b/src/pipecat/services/google/llm_vertex.py index 22b6258a5..ee66c1f20 100644 --- a/src/pipecat/services/google/llm_vertex.py +++ b/src/pipecat/services/google/llm_vertex.py @@ -83,14 +83,23 @@ class GoogleVertexLLMService(OpenAILLMService): self._api_key = self._get_api_token(credentials, credentials_path) super().__init__( - api_key=self._api_key, base_url=base_url, model=model, params=params, **kwargs + api_key=self._api_key, + base_url=base_url, + model=model, + params=params, + **kwargs, ) @staticmethod def _get_base_url(params: InputParams) -> str: """Construct the base URL for Vertex AI API.""" + # Determine the correct API host based on location + if params.location == "global": + api_host = "aiplatform.googleapis.com" + else: + api_host = f"{params.location}-aiplatform.googleapis.com" return ( - f"https://{params.location}-aiplatform.googleapis.com/v1/" + f"https://{api_host}/v1/" f"projects/{params.project_id}/locations/{params.location}/endpoints/openapi" ) @@ -118,12 +127,14 @@ class GoogleVertexLLMService(OpenAILLMService): if credentials: # Parse and load credentials from JSON string creds = service_account.Credentials.from_service_account_info( - json.loads(credentials), scopes=["https://www.googleapis.com/auth/cloud-platform"] + json.loads(credentials), + scopes=["https://www.googleapis.com/auth/cloud-platform"], ) elif credentials_path: # Load credentials from JSON file creds = service_account.Credentials.from_service_account_file( - credentials_path, scopes=["https://www.googleapis.com/auth/cloud-platform"] + credentials_path, + scopes=["https://www.googleapis.com/auth/cloud-platform"], ) else: try: From 3c1b41df1300625fa3a52c492bb15309aad51ae6 Mon Sep 17 00:00:00 2001 From: Pablo Elgueta Date: Thu, 18 Sep 2025 17:39:03 +0100 Subject: [PATCH 2/2] docs: add changelog entry for global location support - Document the new global location support in GoogleVertexLLMService - Explain the difference between regional and global API hosts - Follow Keep a Changelog format --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c56f58491..8f91beb00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added support for global location in `GoogleVertexLLMService`. The service now + supports both regional locations (e.g., "us-east4") and the "global" location + for Vertex AI endpoints. When using "global" location, the service will use + `aiplatform.googleapis.com` as the API host instead of the regional format. + - Added `on_pipeline_finished` event to `PipelineTask`. This event will get fired when the pipeline is done running. This can be the result of a `StopFrame`, `CancelFrame` or `EndFrame`.