web_search无法使用
ZzzIKnow opened this issue · comments
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
请问可以在 kwaiagents/tools/search.py
下加入下列代码,然后单独运行一下kwaiagents/tools/search.py
吗?
if __name__ == "__main__":
search_tool = SearchTool()
print(search_tool("刘德华老婆"))
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
我这网址是可以访问的,在工具类下也不能使用
Hi 你在命令行代理开了不,终端里直接curl https://api.duckduckgo.com/
能有返回吗
duckduckgo_search
库为逆向库,需要实时跟进版本,请运行 pip -U duckduckgo_search
升级依赖
Hi 你在命令行代理开了不,终端里直接
curl https://api.duckduckgo.com/
能有返回吗
需要在命令行中开代理嘛
需要的,指定 http_proxy
重新刷一下dns缓存看看是否可以么?curl一下主网站呢? curl https://duckduckgo.com/