源代码
from langchain.tools import YouTubeSearchTool,Tool
proxies = {'HTTP': 'HTTP://127.0.0.1:7890', 'HTTPS': 'HTTP://127.0.0.1:7890'}
tool = YouTubeSearchTool(proxies ='http://localhost:7890')
tool.run("langchain")
出现错误:
requests.exceptions.ProxyError: HTTPSConnectionPool(host='youtube.com', port=443): Max retries exceeded with url: /results?search_query=langchain (Caused by ProxyError('Unable to connect to proxy', SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1135)'))))
同样的proxies参数下可以连接到hugging face
ping不通youtube.com
但是在网页上打得开
错误详情:
urllib3.exceptions.SSLError: TLS/SSL connection has been closed (EOF) (_ssl.c:1135)
The above exception was the direct cause of the following exception:
urllib3.exceptions.ProxyError: ('Unable to connect to proxy', SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1135)')))
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\1\.conda\envs\prompt02\lib\site-packages\requests\adapters.py", line 670, in send
resp = conn.urlopen(
File "C:\Users\1\.conda\envs\prompt02\lib\site-packages\urllib3\connectionpool.py", line 843, in urlopen
retries = retries.increment(
File "C:\Users\1\.conda\envs\prompt02\lib\site-packages\urllib3\util\retry.py", line 519, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='youtube.com', port=443): Max retries exceeded with url: /results?search_query=langchain (Caused by ProxyError('Unable to connect to proxy', SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1135)'))))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/1/Desktop/Project/learnprompt/agent_llm.py", line 66, in <module>
tool.run("langchain")
File "C:\Users\1\.conda\envs\prompt02\lib\site-packages\langchain_core\tools.py", line 635, in run
raise error_to_raise
File "C:\Users\1\.conda\envs\prompt02\lib\site-packages\langchain_core\tools.py", line 608, in run
response = context.run(self._run, *tool_args, **tool_kwargs)
File "C:\Users\1\.conda\envs\prompt02\lib\site-packages\langchain_community\tools\youtube\search.py", line 55, in _run
return self._search(person, num_results)
File "C:\Users\1\.conda\envs\prompt02\lib\site-packages\langchain_community\tools\youtube\search.py", line 35, in _search
results = YoutubeSearch(person, num_results).to_json()
File "C:\Users\1\.conda\envs\prompt02\lib\site-packages\youtube_search\__init__.py", line 10, in __init__
self.videos = self._search()
File "C:\Users\1\.conda\envs\prompt02\lib\site-packages\youtube_search\__init__.py", line 16, in _search
response = requests.get(url).text
File "C:\Users\1\.conda\envs\prompt02\lib\site-packages\requests\api.py", line 75, in get
return request("get", url, params=params, **kwargs)
File "C:\Users\1\.conda\envs\prompt02\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\1\.conda\envs\prompt02\lib\site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\1\.conda\envs\prompt02\lib\site-packages\requests\sessions.py", line 704, in send
r = adapter.send(request, **kwargs)
File "C:\Users\1\.conda\envs\prompt02\lib\site-packages\requests\adapters.py", line 699, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='youtube.com', port=443): Max retries exceeded with url: /results?search_query=langchain (Caused by ProxyError('Unable to connect to proxy', SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1135)'))))