devika
devika copied to clipboard
Add DuckDuckGo Search
Pls add duckduckgo search it doesn't require a api key to use their search
I did it for u guys, ur welcome works well with openhermes uv pip install duckduckgo_search
backup devika/src/browser/search.py
cd devika/src/browser/ cp search.py search-copy.py
copy pasta the code below into search.py
import requests
from duckduckgo_search import DDGS
from src.config import Config
class BingSearch:
def __init__(self):
self.config = Config()
self.query_result = None
def search(self, query):
try:
self.query_result = DDGS().text(query, max_results=3)
self.query_result = self.query_result.json()
return self.query_result
except Exception as err:
return err
def get_first_link(self):
print(self.query_result)
return self.query_result[0]["href"]
Thanks for this, very helpful! I tried openhermes on your recommendation and it's surprisingly good too!