FD900's picture
Create search.py
4696aa7 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)