mirror of
https://github.com/Mintplex-Labs/langchain-python.git
synced 2026-08-27 09:21:30 -04:00
b7f2061736
Co-authored-by: Cao Hoang <65607230+cnhhoang850@users.noreply.github.com> Co-authored-by: vowelparrot <130414180+vowelparrot@users.noreply.github.com>
28 lines
896 B
Python
28 lines
896 B
Python
"""Tool for the Google search API."""
|
|
|
|
from pydantic import Field
|
|
|
|
from langchain.tools.base import BaseTool
|
|
from langchain.utilities.google_places_api import GooglePlacesAPIWrapper
|
|
|
|
|
|
class GooglePlacesTool(BaseTool):
|
|
"""Tool that adds the capability to query the Google places API."""
|
|
|
|
name = "Google Places"
|
|
description = (
|
|
"A wrapper around Google Places. "
|
|
"Useful for when you need to validate or "
|
|
"discover addressed from ambiguous text. "
|
|
"Input should be a search query."
|
|
)
|
|
api_wrapper: GooglePlacesAPIWrapper = Field(default_factory=GooglePlacesAPIWrapper)
|
|
|
|
def _run(self, query: str) -> str:
|
|
"""Use the tool."""
|
|
return self.api_wrapper.run(query)
|
|
|
|
async def _arun(self, query: str) -> str:
|
|
"""Use the tool asynchronously."""
|
|
raise NotImplementedError("GooglePlacesRun does not support async")
|