From 6306a033cc95090a5f02203451ed6dd38c416c36 Mon Sep 17 00:00:00 2001 From: Rafael Moraes Date: Mon, 3 Apr 2023 15:11:15 -0400 Subject: [PATCH] Fixed googlesearch dependency issue Swapped the googlesearch package for the duckduckgo-search. It uses the ddg instant answer API and works very similarly to the googlesearch one. --- requirements-alternative.txt | 14 -------------- requirements.txt | 2 +- scripts/commands.py | 4 ++-- 3 files changed, 3 insertions(+), 17 deletions(-) delete mode 100644 requirements-alternative.txt diff --git a/requirements-alternative.txt b/requirements-alternative.txt deleted file mode 100644 index a2f2723d..00000000 --- a/requirements-alternative.txt +++ /dev/null @@ -1,14 +0,0 @@ -# I wasn't having any luck installing the requirements.txt file in Mac or Linux -# But this seems to work. -# The biggest difference is docker 5 instead of 6, because of this silliness: -# -# The conflict is caused by: -# The user requested requests>=2.26.0 -# docker 6.0.1 depends on requests>=2.26.0 -# googlesearch-python 1.1.0 depends on requests==2.25.1 -docker==5.0.3 - -# I'd love to fix this in a cleaner way - -# Now go ahead and install the rest of what requirements.txt says: --r requirements.txt diff --git a/requirements.txt b/requirements.txt index 5f51bdf5..0fcdfb45 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,5 +8,5 @@ readability-lxml==0.8.1 requests tiktoken==0.3.3 docker -googlesearch-python +duckduckgo-search # Googlesearch python seems to be a bit cursed, anyone good at fixing thigns like this? \ No newline at end of file diff --git a/scripts/commands.py b/scripts/commands.py index 2e332711..2d98a2b2 100644 --- a/scripts/commands.py +++ b/scripts/commands.py @@ -9,7 +9,7 @@ import ai_functions as ai from file_operations import read_file, write_to_file, append_to_file, delete_file from execute_code import execute_python_file from json_parser import fix_and_parse_json -from googlesearch import search +from duckduckgo_search import ddg cfg = Config() @@ -103,7 +103,7 @@ def get_datetime(): def google_search(query, num_results=8): search_results = [] - for j in search(query, num_results=num_results): + for j in ddg(query, max_results=num_results): search_results.append(j) return json.dumps(search_results, ensure_ascii=False, indent=4)