Skip to content

feat: add support for google maps grounding#1478

Merged
VisargD merged 5 commits into
Portkey-AI:mainfrom
b4s36t4:fix/vertex-maps-grounding
Dec 23, 2025
Merged

feat: add support for google maps grounding#1478
VisargD merged 5 commits into
Portkey-AI:mainfrom
b4s36t4:fix/vertex-maps-grounding

Conversation

@b4s36t4

@b4s36t4 b4s36t4 commented Dec 22, 2025

Copy link
Copy Markdown
Contributor

Description: (required)
Adds support for grounding with google maps

Tests Run/Test cases added: (required)

  • Add tool with widget, lat and lng
  • Tool choice shouldn't breaking

Type of Change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

cURL

curl --location 'localhost:8787/v1/chat/completions' \
--header 'x-portkey-api-key: <api_key>' \
--header 'x-portkey-provider: <provider>' \
--header 'Content-Type: application/json' \
--data '{
    "model": "gemini-2.5-flash-lite",
    "messages": [
        {
            "role": "user",
            "content": "What restaurants are nearby?"
        }
    ],
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "googleMaps",
                "description": "Get the restaurants in a given location",
                "parameters": {
                    "enable_widget": true,
                    "retrieval_config": {
                        "latLng": {
                            "latitude": 37.7749,
                            "longitude": -122.4194 // San Francisco
                        }
                    }
                }
            }
        }
    ],
    "tool_choice": "auto"
}'

Comment thread src/providers/google-vertex-ai/chatComplete.ts Outdated
Comment thread src/providers/google-vertex-ai/chatComplete.ts
@VisargD VisargD requested a review from Copilot December 22, 2025 13:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for Google Maps grounding functionality to the Google and Google Vertex AI providers. The implementation allows users to specify geographic coordinates for location-based queries through a new googleMaps tool.

Key changes:

  • Added retrievalConfig to GoogleToolConfig interface to support latitude/longitude parameters
  • Implemented Google Maps tool detection and configuration in both Google and Vertex AI providers
  • Added tool transformation logic to handle the googleMaps tool with widget support

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/providers/google/chatComplete.ts Added retrievalConfig to GoogleToolConfig interface and implemented Google Maps tool detection/configuration in tool_choice parameter handling
src/providers/google-vertex-ai/utils.ts Added googleMaps and google_maps to the list of recognized Google tools and implemented transformation logic for Google Maps tool
src/providers/google-vertex-ai/chatComplete.ts Mirrored Google provider changes for Vertex AI, adding Google Maps tool detection and configuration in tool_choice parameter handling
Comments suppressed due to low confidence (1)

src/providers/google/chatComplete.ts:1

  • The Google Maps tool detection logic (lines 338-346) is duplicated from the default function (lines 450-458). Consider extracting this into a helper function to avoid code duplication and improve maintainability.
import { GOOGLE } from '../../globals';

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 324 to +347
return toolConfig;
}
const googleMapsTool = params.tools?.find(
(tool) =>
tool.function?.name === 'googleMaps' ||
tool.function?.name === 'google_maps'
);
if (googleMapsTool) {
toolConfig.retrievalConfig =
googleMapsTool.function?.parameters?.retrieval_config;
}
return toolConfig;

Copilot AI Dec 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Google Maps tool detection logic (lines 338-346) is duplicated from the default function (lines 307-315). Consider extracting this into a helper function to avoid code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
@b4s36t4 b4s36t4 force-pushed the fix/vertex-maps-grounding branch from 417b079 to a682340 Compare December 22, 2025 14:37
@VisargD VisargD merged commit f605bc0 into Portkey-AI:main Dec 23, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants