mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-10 15:06:18 +00:00
improve duck duck go tool (#13165)
This commit is contained in:
parent
850336bcf1
commit
0a2b1c7471
@ -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…
Reference in New Issue
Block a user