mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
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:
parent
7c24a6b9d1
commit
095937ad52
@ -85,6 +85,7 @@ class GooglePlacesAPIWrapper(BaseModel):
|
|||||||
def fetch_place_details(self, place_id: str) -> Optional[str]:
|
def fetch_place_details(self, place_id: str) -> Optional[str]:
|
||||||
try:
|
try:
|
||||||
place_details = self.google_map_client.place(place_id)
|
place_details = self.google_map_client.place(place_id)
|
||||||
|
place_details["place_id"] = place_id
|
||||||
formatted_details = self.format_place_details(place_details)
|
formatted_details = self.format_place_details(place_details)
|
||||||
return formatted_details
|
return formatted_details
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -101,9 +102,11 @@ class GooglePlacesAPIWrapper(BaseModel):
|
|||||||
"formatted_phone_number", "Unknown"
|
"formatted_phone_number", "Unknown"
|
||||||
)
|
)
|
||||||
website = place_details.get("result", {}).get("website", "Unknown")
|
website = place_details.get("result", {}).get("website", "Unknown")
|
||||||
|
place_id = place_details.get("result", {}).get("place_id", "Unknown")
|
||||||
|
|
||||||
formatted_details = (
|
formatted_details = (
|
||||||
f"{name}\nAddress: {address}\n"
|
f"{name}\nAddress: {address}\n"
|
||||||
|
f"Google place ID: {place_id}\n"
|
||||||
f"Phone: {phone_number}\nWebsite: {website}\n\n"
|
f"Phone: {phone_number}\nWebsite: {website}\n\n"
|
||||||
)
|
)
|
||||||
return formatted_details
|
return formatted_details
|
||||||
|
Loading…
Reference in New Issue
Block a user