Repository navigation
pref: add proxies kwargs in duckduckgo tool run func #501
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,9 @@ def _run(self, keyword: str, **kwargs) -> Union[str, List[str]]: | |
| result_type="original" | ||
| """ | ||
| from duckduckgo_search.exceptions import RateLimitException | ||
|
|
||
| if "proxies" in kwargs: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This mutates |
||
| if kwargs["proxies"]: | ||
| self.api_wrapper.proxies = kwargs["proxies"] | ||
| attempt = 0 | ||
| while attempt < self.max_retry: | ||
| try: | ||
|
|
@@ -80,6 +82,9 @@ def _run(self, keyword: str, **kwargs) -> Union[str, List[Dict[str, str]]]: | |
| default is string. Return List[Dict[str, str]] type data if you pass | ||
| result_type="original" | ||
| """ | ||
| if "proxies" in kwargs: | ||
| if kwargs["proxies"]: | ||
| self.api_wrapper.proxies = kwargs["proxies"] | ||
| result = self.api_wrapper.query_by_formatted_results(keyword, **kwargs) | ||
| if "return_type" in kwargs and kwargs["return_type"] == "original": | ||
| return result | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duckduckgo_search==3.9.11definesDDGS(headers=None, proxies=None, timeout=10), soDDGS(self.proxies)binds the proxy string toheaders, notproxies. This means the proxy is never applied. Please pass it explicitly asDDGS(proxies=self.proxies)here and in the other call site.