File size: 425 Bytes
bfb5d08 |
1 2 3 4 5 6 7 8 9 10 11 12 |
from langchain_community.utilities import DuckDuckGoSearchAPIWrapper
from langchain_community.tools import DuckDuckGoSearchResults
from langchain.agents import tool
@tool
def search(query: str) -> str:
"""Search in DuckDuckGo"""
wrapper = DuckDuckGoSearchAPIWrapper(max_results=5, safesearch="off", time="w")
search = DuckDuckGoSearchResults(api_wrapper=wrapper)
return str(search.invoke(query))
|