mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-20 01:54:14 +00:00
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:
@@ -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",
|
||||
]
|
||||
|
1
langchain/tools/google_places/__init__.py
Normal file
1
langchain/tools/google_places/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Google Places API Toolkit."""
|
27
langchain/tools/google_places/tool.py
Normal file
27
langchain/tools/google_places/tool.py
Normal 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")
|
Reference in New Issue
Block a user