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
This commit is contained in:
Boris Nieuwenhuis 2023-07-20 18:04:31 +02:00 committed by GitHub
parent 7c24a6b9d1
commit 095937ad52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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