Harrison/google places (#3207)

Co-authored-by: Cao Hoang <65607230+cnhhoang850@users.noreply.github.com>
Co-authored-by: vowelparrot <130414180+vowelparrot@users.noreply.github.com>
This commit is contained in:
Harrison Chase
2023-04-20 07:57:07 -07:00
committed by GitHub
parent 34fb56b633
commit b7f2061736
6 changed files with 249 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
from langchain.tools.base import BaseTool
from langchain.tools.ddg_search.tool import DuckDuckGoSearchTool
from langchain.tools.google_places.tool import GooglePlacesTool
from langchain.tools.ifttt import IFTTTWebhook
from langchain.tools.openapi.utils.api_models import APIOperation
from langchain.tools.openapi.utils.openapi_utils import OpenAPISpec
@@ -13,5 +14,6 @@ __all__ = [
"AIPluginTool",
"OpenAPISpec",
"APIOperation",
"GooglePlacesTool",
"DuckDuckGoSearchTool",
]

View File

@@ -0,0 +1 @@
"""Google Places API Toolkit."""

View File

@@ -0,0 +1,27 @@
"""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")