You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
langchain/langchain/tools/google_search/toolkit.py

27 lines
784 B
Python

"""Tool for the Google search API."""
from typing import List
from langchain.tools.base import BaseTool, BaseToolkit
from langchain.tools.google_search.tool import GoogleSearchRun
from langchain.utilities.google_search import GoogleSearchAPIWrapper
class GoogleSearchToolkit(BaseToolkit):
"""Tool that adds the capability to query the Google search API."""
google_subscription_key: str
google_search_url: str
def get_tools(self) -> List[BaseTool]:
"""Get the tools in the toolkit."""
wrapper = GoogleSearchAPIWrapper(
google_api_key=self.google_subscription_key,
google_search_url=self.google_search_url,
)
return [
GoogleSearchRun(
api_wrapper=wrapper,
)
]