improve duck duck go tool (#13165)

pull/13173/head
Harrison Chase 11 months ago committed by GitHub
parent 850336bcf1
commit 0a2b1c7471
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,14 +1,18 @@
"""Tool for the DuckDuckGo search API."""
import warnings
from typing import Any, Optional
from typing import Any, Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import Field
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.base import BaseTool
from langchain.utilities.duckduckgo_search import DuckDuckGoSearchAPIWrapper
class DDGInput(BaseModel):
query: str = Field(description="search query to look up")
class DuckDuckGoSearchRun(BaseTool):
"""Tool that queries the DuckDuckGo search API."""
@ -21,6 +25,7 @@ class DuckDuckGoSearchRun(BaseTool):
api_wrapper: DuckDuckGoSearchAPIWrapper = Field(
default_factory=DuckDuckGoSearchAPIWrapper
)
args_schema: Type[BaseModel] = DDGInput
def _run(
self,
@ -45,6 +50,7 @@ class DuckDuckGoSearchResults(BaseTool):
default_factory=DuckDuckGoSearchAPIWrapper
)
backend: str = "api"
args_schema: Type[BaseModel] = DDGInput
def _run(
self,

Loading…
Cancel
Save