From 095937ad52477e64732bd07e9b1a3dec3c7bb038 Mon Sep 17 00:00:00 2001 From: Boris Nieuwenhuis Date: Thu, 20 Jul 2023 18:04:31 +0200 Subject: [PATCH] Add google place ID to google places tool response (#7789) - Description: this change will add the google place ID of the found location to the response of the GooglePlacesTool - Issue: Not applicable - Dependencies: no dependencies - Tag maintainer: @hinthornw - Twitter handle: Not applicable --- langchain/utilities/google_places_api.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/langchain/utilities/google_places_api.py b/langchain/utilities/google_places_api.py index 957fe9374c..8b8ea7a93a 100644 --- a/langchain/utilities/google_places_api.py +++ b/langchain/utilities/google_places_api.py @@ -85,6 +85,7 @@ class GooglePlacesAPIWrapper(BaseModel): def fetch_place_details(self, place_id: str) -> Optional[str]: try: place_details = self.google_map_client.place(place_id) + place_details["place_id"] = place_id formatted_details = self.format_place_details(place_details) return formatted_details except Exception as e: @@ -101,9 +102,11 @@ class GooglePlacesAPIWrapper(BaseModel): "formatted_phone_number", "Unknown" ) website = place_details.get("result", {}).get("website", "Unknown") + place_id = place_details.get("result", {}).get("place_id", "Unknown") formatted_details = ( f"{name}\nAddress: {address}\n" + f"Google place ID: {place_id}\n" f"Phone: {phone_number}\nWebsite: {website}\n\n" ) return formatted_details