Upload code/chat_internet.py with huggingface_hub
Browse files75 unmodified lines767778798081828384858675 unmodified linessource = "DuckDuckGo"try:from duckduckgo_search import DDGSwith DDGS() as ddgs:results = list(ddgs.text(query, max_results=3))except Exception as e:print(f"\033[31m⚠️ DuckDuckGo Error: {e}\033[0m")return ""if not results:75 unmodified lines76777879808182838485868788899091929394959697989910010175 unmodified linessource = "DuckDuckGo"try:import sysimport os# Suppress all stderr warnings (like DeprecationWarnings from Jupyter)old_stderr = sys.stderrsys.stderr = open(os.devnull, 'w')from duckduckgo_search import DDGSwith DDGS() as ddgs:results = list(ddgs.text(query, max_results=3))sys.stderr.close()sys.stderr = old_stderrexcept Exception as e:try:sys.stderr.close()sys.stderr = old_stderrexcept:passreturn ""if not results:
code/chat_internet.py+16-1