Open Qboy-1214 opened 1 year ago
看起来像是因为没配置 proxy。你是使用接入点连接的 bing 吗?
根据 adapter/ms/bing.py 中的
async def __download_image(self, url):
async with aiohttp.ClientSession() as session:
async with session.get(url, proxy=self.bot.proxy) as resp:
if resp.status == 200:
return GraiaImage(data_bytes=await resp.read())
可以看出,当且仅当 bing bot 在配置文件中了 proxy
时才可用。
如果你是通过接入点访问的,那么就会出现这个错误。
目前 接入点 仅配置了与 bing 的聊天,没有配置画图的API,我也不懂如何配置,需要其他人来解决这个问题
使用proxy连接bing而不是使用接入点连接bing。
在你的 config.cfg
中的添加下面的配置,并删除接入点的配置,应该就可以了
[[bing.accounts]]
proxy="http://127.0.0.1:1080" #你的代理地址
同无法画画,为什么地址会变成www.bing.comhttps:443
呢
2023-04-20 09:23:03.996 | INFO | graia.ariadne.model:log:82 - 1852637873: [RECV][司南(xxx)] -> #画一个鸽子
2023-04-20 09:23:05.905 | DEBUG | middlewares.concurrentlock:handle_request:40 - [Concurrent] 排队中,前面还有 0 个人!
2023-04-20 09:23:05.907 | DEBUG | middlewares.concurrentlock:handle_request:42 - [Concurrent] 排到了!
2023-04-20 09:23:05.908 | DEBUG | middlewares.timeout:create_timeout_task:55 - [Timeout] 开始计时……
2023-04-20 09:23:05.910 | DEBUG | adapter.ms.bing:text_to_img:98 - [Bing Image] Prompt: 一个鸽子
2023-04-20 09:23:06.482 | ERROR | universal:request:240 - Cannot connect to host www.bing.comhttps:443 ssl:default [Name or service not known]
Traceback (most recent call last):
File "/home/xc9/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1152, in _create_direct_connection
hosts = await asyncio.shield(host_resolved)
│ │ └ <Task finished name='Task-33' coro=<TCPConnector._resolve_host() done, defined at /home/xc9/.local/lib/python3.11/site-packag...
│ └ <function shield at 0x7f6ec0f20a40>
└ <module 'asyncio' from '/usr/lib/python3.11/asyncio/__init__.py'>
File "/home/xc9/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 874, in _resolve_host
addrs = await self._resolver.resolve(host, port, family=self._family)
│ │ │ │ │ │ └ 0
│ │ │ │ │ └ <aiohttp.connector.TCPConnector object at 0x7f6ebbb55590>
│ │ │ │ └ 443
│ │ │ └ 'www.bing.comhttps'
│ │ └ <function ThreadedResolver.resolve at 0x7f6ebfc44540>
│ └ <aiohttp.resolver.ThreadedResolver object at 0x7f6ebbb57550>
└ <aiohttp.connector.TCPConnector object at 0x7f6ebbb55590>
File "/home/xc9/.local/lib/python3.11/site-packages/aiohttp/resolver.py", line 33, in resolve
infos = await self._loop.getaddrinfo(
│ │ └ <function BaseEventLoop.getaddrinfo at 0x7f6ec0f2e200>
│ └ <_UnixSelectorEventLoop running=True closed=False debug=False>
└ <aiohttp.resolver.ThreadedResolver object at 0x7f6ebbb57550>
File "/usr/lib/python3.11/asyncio/base_events.py", line 867, in getaddrinfo
return await self.run_in_executor(
│ └ <function BaseEventLoop.run_in_executor at 0x7f6ec0f2e020>
└ <_UnixSelectorEventLoop running=True closed=False debug=False>
File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
│ │ └ None
│ └ None
└ None
File "/usr/lib/python3.11/socket.py", line 962, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
│ │ │ │ │ │ │ └ <AddressInfo.AI_ADDRCONFIG: 32>
│ │ │ │ │ │ └ 0
│ │ │ │ │ └ <SocketKind.SOCK_STREAM: 1>
│ │ │ │ └ 0
│ │ │ └ 443
│ │ └ 'www.bing.comhttps'
│ └ <built-in function getaddrinfo>
└ <module '_socket' (built-in)>
socket.gaierror: [Errno -2] Name or service not known
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/xc9/act/bot2/chatgpt-mirai-qq-bot/bot.py", line 41, in <module>
loop.run_until_complete(asyncio.gather(*bots))
│ │ │ │ └ [<Task pending name='Task-2' coro=<start_task() running at /home/xc9/act/bot2/chatgpt-mirai-qq-bot/platforms/ariadne_bot.py:3...
│ │ │ └ <function gather at 0x7f6ec0f20860>
│ │ └ <module 'asyncio' from '/usr/lib/python3.11/asyncio/__init__.py'>
│ └ <function BaseEventLoop.run_until_complete at 0x7f6ec0f2d760>
└ <_UnixSelectorEventLoop running=True closed=False debug=False>
File "/usr/lib/python3.11/asyncio/base_events.py", line 640, in run_until_complete
self.run_forever()
│ └ <function BaseEventLoop.run_forever at 0x7f6ec0f2d6c0>
└ <_UnixSelectorEventLoop running=True closed=False debug=False>
File "/usr/lib/python3.11/asyncio/base_events.py", line 607, in run_forever
self._run_once()
│ └ <function BaseEventLoop._run_once at 0x7f6ec0f2f4c0>
└ <_UnixSelectorEventLoop running=True closed=False debug=False>
File "/usr/lib/python3.11/asyncio/base_events.py", line 1922, in _run_once
handle._run()
│ └ <function Handle._run at 0x7f6ec0ed42c0>
└ <Handle <TaskStepMethWrapper object at 0x7f6ebbb3db40>()>
File "/usr/lib/python3.11/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
│ │ │ │ │ └ <member '_args' of 'Handle' objects>
│ │ │ │ └ <Handle <TaskStepMethWrapper object at 0x7f6ebbb3db40>()>
│ │ │ └ <member '_callback' of 'Handle' objects>
│ │ └ <Handle <TaskStepMethWrapper object at 0x7f6ebbb3db40>()>
│ └ <member '_context' of 'Handle' objects>
└ <Handle <TaskStepMethWrapper object at 0x7f6ebbb3db40>()>
> File "/home/xc9/act/bot2/chatgpt-mirai-qq-bot/universal.py", line 206, in request
async for rendered in task:
└ <async_generator object retry.<locals>.decorator.<locals>.wrapper at 0x7f6ebcf49800>
File "/home/xc9/act/bot2/chatgpt-mirai-qq-bot/utils/retry.py", line 21, in wrapper
async for result in func(*args, **kwargs):
│ │ └ {'prompt': '画一个鸽子', 'chain': MessageChain([Plain(text='画一个鸽子')]), 'name': '司南'}
│ └ (<conversation.ConversationContext object at 0x7f6ebbb14ad0>,)
└ <function ConversationContext.ask at 0x7f6ebd972de0>
File "/home/xc9/act/bot2/chatgpt-mirai-qq-bot/conversation.py", line 156, in ask
images = await self.drawing_adapter.text_to_img(prompt)
│ │ │ └ '一个鸽子'
│ │ └ <function BingAdapter.text_to_img at 0x7f6ebda4c0e0>
│ └ <adapter.ms.bing.BingAdapter object at 0x7f6ebdb20250>
└ <conversation.ConversationContext object at 0x7f6ebbb14ad0>
File "/home/xc9/act/bot2/chatgpt-mirai-qq-bot/adapter/ms/bing.py", line 104, in text_to_img
images = await image_generator.get_images(prompt)
│ │ └ '一个鸽子'
│ └ <function ImageGenAsync.get_images at 0x7f6ebda2fec0>
└ <BingImageCreator.ImageGenAsync object at 0x7f6ebe814bd0>
File "/home/xc9/.local/lib/python3.11/site-packages/BingImageCreator.py", line 202, in get_images
await self.session.get(f"{BING_URL}{redirect_url}")
│ │ └ <function ClientSession.get at 0x7f6ebfc8efc0>
│ └ <aiohttp.client.ClientSession object at 0x7f6ebbb17d50>
└ <BingImageCreator.ImageGenAsync object at 0x7f6ebe814bd0>
File "/home/xc9/.local/lib/python3.11/site-packages/aiohttp/client.py", line 536, in _request
conn = await self._connector.connect(
│ └ None
└ <aiohttp.client.ClientSession object at 0x7f6ebbb17d50>
File "/home/xc9/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect
proto = await self._create_connection(req, traces, timeout)
│ │ │ │ └ ClientTimeout(total=300, connect=None, sock_read=None, sock_connect=None)
│ │ │ └ []
│ │ └ <aiohttp.client_reqrep.ClientRequest object at 0x7f6ebbb63c90>
│ └ <function TCPConnector._create_connection at 0x7f6ebfc46840>
└ <aiohttp.connector.TCPConnector object at 0x7f6ebbb55590>
File "/home/xc9/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
│ │ │ │ └ ClientTimeout(total=300, connect=None, sock_read=None, sock_connect=None)
│ │ │ └ []
│ │ └ <aiohttp.client_reqrep.ClientRequest object at 0x7f6ebbb63c90>
│ └ <function TCPConnector._create_direct_connection at 0x7f6ebfc46f20>
└ <aiohttp.connector.TCPConnector object at 0x7f6ebbb55590>
File "/home/xc9/.local/lib/python3.11/site-packages/aiohttp/connector.py", line 1166, in _create_direct_connection
raise ClientConnectorError(req.connection_key, exc) from exc
│ │ └ <property object at 0x7f6ebfc1e570>
│ └ <aiohttp.client_reqrep.ClientRequest object at 0x7f6ebbb63c90>
└ <class 'aiohttp.client_exceptions.ClientConnectorError'>
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host www.bing.comhttps:443 ssl:default [Name or service not known]
2023-04-20 09:23:06.936 | INFO | graia.ariadne.model:log:82 - 1852637873: [SEND][司南(xxx)] <- 出现故障!如果这个问题持续出现,请和我说“重置会话” 来开启一段新的会话,或者发送 “回滚对话” 来回溯到上一条对话,你上一条说的我就当作没看见。\n原因:Cannot connect to host www.bing.comhttps:443 ssl:default [Name or service not known]
发生了同样的错误,设置代理无法解决
似乎是proxy配置没有生效,同样配置方法在openai下生效
发生了同样的错误,设置代理无法解决
似乎是proxy配置没有生效,同样配置方法在openai下生效
同样错误
出现故障!如果这个问题持续出现,请和我说“重置会话” 来开启一段新的会话,或者发送 “回滚会话” 来回溯到上一条对话,你上一条说的我就当作没看见。 Cannot connect to host www.bing.comhttps:443 ssl:default [Name or service not known]
我也碰到了这个问题
同问+1
发生了同样的错误,设置代理无法解决
似乎是proxy配置没有生效,同样配置方法在openai下生效
经过测试,如果只设置config内bing选项下的proxy内容是无法成功使用http代理获取bing画图的。 我的处理方法是,将docker部署在有代理环境的系统下,成功使用bing绘画功能:
发生了同样的错误,设置代理无法解决 似乎是proxy配置没有生效,同样配置方法在openai下生效
同样错误
出现故障!如果这个问题持续出现,请和我说“重置会话” 来开启一段新的会话,或者发送 “回滚会话” 来回溯到上一条对话,你上一条说的我就当作没看见。 Cannot connect to host www.bing.comhttps:443 ssl:default [Name or service not known]
我也遇到了这个错误,代理是可用的,但是连接的地址为什么是 www.bing.comhttps:443 ?
发生了同样的错误,设置代理无法解决 似乎是proxy配置没有生效,同样配置方法在openai下生效
经过测试,如果只设置config内bing选项下的proxy内容是无法成功使用http代理获取bing画图的。 我的处理方法是,将docker部署在有代理环境的系统下,成功使用bing绘画功能:
我设置了机器http_proxy和https_proxy,还是不行。 bing画图和edgeTTS都是报类似的错误
只能部署在国外vps,本地环境即使设置了代理,bing的画图功能也无法使用。不清楚其中的原因。
画图失败!原因: 404, message='Not Found', url=URL('https://tse4.mm.bing.net/th/id/OIG.LNn_HzBbMMRal_eNoaoM')
画图失败!原因: 画图失败:Redirect failed
看起来像是因为没配置 proxy。你是使用接入点连接的 bing 吗?
根据 adapter/ms/bing.py 中的
async def __download_image(self, url): async with aiohttp.ClientSession() as session: async with session.get(url, proxy=self.bot.proxy) as resp: if resp.status == 200: return GraiaImage(data_bytes=await resp.read())
可以看出,当且仅当 bing bot 在配置文件中了
proxy
时才可用。如果你是通过接入点访问的,那么就会出现这个错误。
目前 接入点 仅配置了与 bing 的聊天,没有配置画图的API,我也不懂如何配置,需要其他人来解决这个问题
临时解决办法
使用proxy连接bing而不是使用接入点连接bing。
在你的
config.cfg
中的添加下面的配置,并删除接入点的配置,应该就可以了[[bing.accounts]] proxy="http://127.0.0.1:1080" #你的代理地址
只在config.cfg里面写还不行,我在docker-compose.yaml里面chatgpt那一段加入了代理参数就能画了:
chatgpt:
image: lss233/chatgpt-mirai-qq-bot:browser-version
restart: always
environment:
LANG: 'C.UTF-8'
# 设置代理
HTTP_PROXY: http://192.168.1.101:7890
HTTPS_PROXY: http://192.168.1.101:7890
ports:
- 8554:8554/tcp
volumes:
- ./config.cfg:/app/config.cfg
- ./data:/app/data
- ./presets:/app/presets
提交 issue 前,请先确认:
表现
bing画画报错:
运行环境:
复现步骤
描述你是如何触发这个 BUG 的
预期行为
bing画一幅画
截图
其他内容
此处填写其他内容,没有可跳过