Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate google search to use DDGS.text function #4383

Conversation

kinance
Copy link
Contributor

@kinance kinance commented May 24, 2023

Background

The new duckduckgo_search version deprecated the ddg function and max_result parameters. Users are seeing the following warning messages when auto-gpt executes google command.

*\AppData\Local\Programs\Python\Python310\lib\site-packages\duckduckgo_search\compat.py:20: UserWarning: ddg is deprecated. Use DDGS().text() generator warnings.warn("ddg is deprecated. Use DDGS().text() generator")
UserWarning: parameter max_results is deprecated, use DDGS().text() warnings.warn("parameter max_results is deprecated, use DDGS().text()")

This fixes #4376

Changes

Migrate the search func to use the new function and use islice to limit the iterators up to max_results. Itertools.islice handles the iterators in an efficient way. Itertools is a module in python.

Documentation

Test Plan

Updated the google search's integration test

PR Quality Checklist

  • My pull request is atomic and focuses on a single change.
  • I have thoroughly tested my changes with multiple different prompts.
  • I have considered potential risks and mitigations for my changes.
  • I have documented my changes clearly and comprehensively.
  • I have not snuck in any "extra" small tweaks changes.
  • I have run black . and isort . against my code to ensure it passes our linter.

@vercel
Copy link

vercel bot commented May 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) May 24, 2023 4:17pm

@kinance kinance changed the title Use islice to limit up to the max results from generator of new duckd… Migrate the google search func to use the new duckduckgo_search DDGS.text function and support deprecated max_results May 24, 2023
@codecov
Copy link

codecov bot commented May 24, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (438d3e4) 64.90% compared to head (9a9f1f9) 64.91%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4383   +/-   ##
=======================================
  Coverage   64.90%   64.91%           
=======================================
  Files          75       75           
  Lines        3542     3543    +1     
  Branches      520      520           
=======================================
+ Hits         2299     2300    +1     
  Misses       1071     1071           
  Partials      172      172           
Impacted Files Coverage Δ
autogpt/commands/google_search.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ntindle ntindle added this to the v0.4.0 Release milestone May 24, 2023
Copy link
Contributor

@lc0rp lc0rp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just encountered this warning and was about to submit an issue :)

@k-boikov k-boikov changed the title Migrate the google search func to use the new duckduckgo_search DDGS.text function and support deprecated max_results Migrate google search to use DDGS.text function May 24, 2023
@k-boikov k-boikov merged commit 5168cb5 into Significant-Gravitas:master May 24, 2023
@kinance kinance deleted the fix-#4376-duckduckgo_search-deprecated-max-results branch May 24, 2023 16:56
kuwork added a commit to kuwork/Auto-GPT that referenced this pull request May 24, 2023
* master:
  Migrate google search to use DDGS.text function (Significant-Gravitas#4383)
  empty commit to see cassette status (Significant-Gravitas#4382)
  Fix the version of duckduckgo-search to avoid empty result issue (Significant-Gravitas#4368)
  Update get_hyperlinks description (Significant-Gravitas#4122)
  CI: set base repo before `gh pr checkout` (Significant-Gravitas#4363)
  Cassettes should be added in the same pull request, without extra pull request (Significant-Gravitas#4355)
  Improve Azure setup wording in docs (Significant-Gravitas#4325)
  Pass command line args as list (Significant-Gravitas#1486)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
4 participants