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

web_search无法使用 #17

Open
ZzzIKnow opened this issue Jan 9, 2024 · 9 comments
Open

web_search无法使用 #17

ZzzIKnow opened this issue Jan 9, 2024 · 9 comments

Comments

@ZzzIKnow
Copy link

ZzzIKnow commented Jan 9, 2024

Traceback (most recent call last):
File "c:\users\user\desktop\kwaiagents-main\kwaiagents-main\kwaiagents\tools\search.py", line 119, in _retry_search_result
if not search_results and counter >= 2:
^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'search_results' where it is not associated with a value

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\user\desktop\kwaiagents-main\kwaiagents-main\kwaiagents\tools\search.py", line 119, in _retry_search_result
if not search_results and counter >= 2:
^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'search_results' where it is not associated with a value

@ScarletPan
Copy link
Contributor

请问可以在 kwaiagents/tools/search.py 下加入下列代码,然后单独运行一下kwaiagents/tools/search.py吗?

if __name__ == "__main__":
    search_tool = SearchTool()
    print(search_tool("刘德华老婆"))

@ZzzIKnow
Copy link
Author

ZzzIKnow commented Jan 9, 2024

Traceback (most recent call last):
File "C:\Users\User\Desktop\KwaiAgents-main\KwaiAgents-main\kwaiagents\tools\search.py", line 115, in _retry_search_result
search_results = self.get_results_by_ddg(keyword)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\Desktop\KwaiAgents-main\KwaiAgents-main\kwaiagents\tools\search.py", line 99, in get_results_by_ddg
for r in islice(ddgs_gen, self.max_search_nums):
File "D:\Anaconda\envs\RAG\Lib\site-packages\duckduckgo_search\duckduckgo_search.py", line 91, in text
for i, result in enumerate(results, start=1):
File "D:\Anaconda\envs\RAG\Lib\site-packages\duckduckgo_search\duckduckgo_search.py", line 119, in _text_api
vqd = self._get_vqd(keywords)
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Anaconda\envs\RAG\Lib\site-packages\duckduckgo_search\duckduckgo_search.py", line 54, in _get_vqd
resp = self._get_url("POST", "https://duckduckgo.com", data={"q": keywords})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Anaconda\envs\RAG\Lib\site-packages\duckduckgo_search\duckduckgo_search.py", line 50, in _get_url
raise DuckDuckGoSearchException(f"_get_url() {url} {type(ex).name}: {ex}")
duckduckgo_search.exceptions.DuckDuckGoSearchException: _get_url() https://duckduckgo.com RequestsError: Failed to perform, ErrCode: 28, Reason: 'Failed to connect to duckduckgo.com port 443 after 21034 ms: Timed out'. This may be a libcurl error, See https://curl.se/libcurl/c/libcurl-errors.html first for more details.

Traceback (most recent call last):
File "C:\Users\User\Desktop\KwaiAgents-main\KwaiAgents-main\kwaiagents\tools\search.py", line 119, in _retry_search_result
if not search_results and counter >= 2:
^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'search_results' where it is not associated with a value

@ZzzIKnow
Copy link
Author

ZzzIKnow commented Jan 9, 2024

我这网址是可以访问的,在工具类下也不能使用

@ScarletPan
Copy link
Contributor

Hi 你在命令行代理开了不,终端里直接curl https://api.duckduckgo.com/能有返回吗

@sudoskys
Copy link
Contributor

duckduckgo_search 库为逆向库,需要实时跟进版本,请运行 pip -U duckduckgo_search 升级依赖

@ZzzIKnow
Copy link
Author

Hi 你在命令行代理开了不,终端里直接curl https://api.duckduckgo.com/能有返回吗

需要在命令行中开代理嘛

@ScarletPan
Copy link
Contributor

需要的,指定 http_proxy

@ZzzIKnow
Copy link
Author

ZzzIKnow commented Jan 15, 2024

还是原来的问题 代理开了的情况下

image
image

@ScarletPan
Copy link
Contributor

重新刷一下dns缓存看看是否可以么?curl一下主网站呢? curl https://duckduckgo.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants