Spaces:
Sleeping
Sleeping
| from langchain_core.tools import tool | |
| from ddgs import DDGS | |
| 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 | |
| ) | |