dawalina's picture
Different Model
68bf2fc
Raw
History Blame Contribute Delete
452 Bytes
from langchain_core.tools import tool
from ddgs import DDGS
@tool
def search_tool(query: str) -> str:
"""Search the web using DuckDuckGo. Input must be ONLY the search query string, nothing else."""
with DDGS() as ddgs:
results = ddgs.text(query, max_results=3)
if not results:
return "No results found."
return "\n\n".join(
f"{r['title']}\n{r['href']}\n{r['body']}" for r in results
)