FD900's picture
Create tools/search.py
fd607c0 verified
raw
history blame
284 Bytes
from duckduckgo_search import DDGS
def web_search(query, max_results=3):
results = []
with DDGS() as ddgs:
for r in ddgs.text(query):
results.append(r["body"])
if len(results) >= max_results:
break
return "\n".join(results)