mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-19 17:36:00 +00:00
Harrison/ddg (#3206)
Co-authored-by: itai <itai.marks@gmail.com> Co-authored-by: Itai Marks <itaim@users.noreply.github.com> Co-authored-by: Tianyi Pan <60060750+tipani86@users.noreply.github.com> Co-authored-by: Tianyi Pan <tianyi.pan@clobotics.com> Co-authored-by: Adilzhan Ismailov <13088690+aismlv@users.noreply.github.com> Co-authored-by: Justin Flick <Justinjayflick@gmail.com> Co-authored-by: Justin Flick <jflick@homesite.com>
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
"""Core toolkit implementations."""
|
||||
|
||||
from langchain.tools.base import BaseTool
|
||||
from langchain.tools.ddg_search.tool import DuckDuckGoSearchTool
|
||||
from langchain.tools.ifttt import IFTTTWebhook
|
||||
from langchain.tools.openapi.utils.api_models import APIOperation
|
||||
from langchain.tools.openapi.utils.openapi_utils import OpenAPISpec
|
||||
from langchain.tools.plugin import AIPluginTool
|
||||
|
||||
__all__ = ["BaseTool", "IFTTTWebhook", "AIPluginTool", "OpenAPISpec", "APIOperation"]
|
||||
__all__ = [
|
||||
"BaseTool",
|
||||
"IFTTTWebhook",
|
||||
"AIPluginTool",
|
||||
"OpenAPISpec",
|
||||
"APIOperation",
|
||||
"DuckDuckGoSearchTool",
|
||||
]
|
||||
|
1
langchain/tools/ddg_search/__init__.py
Normal file
1
langchain/tools/ddg_search/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""DuckDuckGo Search API toolkit."""
|
28
langchain/tools/ddg_search/tool.py
Normal file
28
langchain/tools/ddg_search/tool.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""Tool for the DuckDuckGo search API."""
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from langchain.tools.base import BaseTool
|
||||
from langchain.utilities.duckduckgo_search import DuckDuckGoSearchAPIWrapper
|
||||
|
||||
|
||||
class DuckDuckGoSearchTool(BaseTool):
|
||||
"""Tool that adds the capability to query the DuckDuckGo search API."""
|
||||
|
||||
name = "DuckDuckGo Search"
|
||||
description = (
|
||||
"A wrapper around DuckDuckGo Search. "
|
||||
"Useful for when you need to answer questions about current events. "
|
||||
"Input should be a search query."
|
||||
)
|
||||
api_wrapper: DuckDuckGoSearchAPIWrapper = Field(
|
||||
default_factory=DuckDuckGoSearchAPIWrapper
|
||||
)
|
||||
|
||||
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("DuckDuckGoSearch does not support async")
|
Reference in New Issue
Block a user