lss233 / chatgpt-mirai-qq-bot

🚀 一键部署!真正的 AI 聊天机器人!支持ChatGPT、文心一言、讯飞星火、Bing、Bard、ChatGLM、POE,多账号,人设调教,虚拟女仆、图片渲染、语音发送 | 支持 QQ、Telegram、Discord、微信 等平台
GNU Affero General Public License v3.0
13.33k stars 1.56k forks source link

[BUG] 无法正常使用bing chat:“'async for' requires an object with __aiter__ method, got coroutine” #252

Closed Qianmo2 closed 1 year ago

Qianmo2 commented 1 year ago

提交 issue 前,请先确认:

表现
向bot发送任意消息,报错“'async for' requires an object with aiter method, got coroutine”,即使发送重置会话也继续相同报错。

运行环境:

复现步骤
描述你是如何触发这个 BUG 的

  1. 启动bot后,发送“切换AI bing”;
  2. 发送任意消息;
  3. 发现报错后,发送重置会话
  4. 仍旧报错。

截图
chatgpt-qq-mirai-1 | 2023-03-04 01:12:33 V/Bot.2463724346: Moki.(2657447616) -> 切换AI bing chatgpt-qq-chatgpt-1 | 2023-03-04 01:12:33.834 | INFO | graia.ariadne.model:log:82 - 2463724346: [RECV][Moki.(2657447616)] -> 切换AI bing chatgpt-qq-chatgpt-1 | 2023-03-04 01:12:33.850 | DEBUG | middlewares.timeout:create_timeout_task:14 - [Timeout] 开始计时…… chatgpt-qq-mirai-1 | 2023-03-04 01:12:35 V/Bot.2463724346: Friend(2657447616) <- [mirai:quote:[mirai:source:ids=[19953], internalIds=[-1733548538], from friend 2657447616 to 2463724346 at 1677892353], content=切换AI bing]已切换至 bing,现在开始和我聊天吧! chatgpt-qq-chatgpt-1 | 2023-03-04 01:12:35.172 | INFO | graia.ariadne.model:log:82 - 2463724346: [SEND][Moki.(2657447616)] <- 已切换至 bing,现在开始和我聊天吧! chatgpt-qq-chatgpt-1 | 2023-03-04 01:12:35.172 | DEBUG | middlewares.timeout:on_respond:38 - [Timeout] 取消计时…… chatgpt-qq-chatgpt-1 | 2023-03-04 01:12:40.494 | INFO | graia.ariadne.model:log:82 - 2463724346: [RECV][Moki.(2657447616)] -> 你好 chatgpt-qq-chatgpt-1 | 2023-03-04 01:12:40.498 | DEBUG | middlewares.timeout:create_timeout_task:14 - [Timeout] 开始计时…… chatgpt-qq-chatgpt-1 | /app/conversation.py:68: RuntimeWarning: coroutine 'BotAdapter.preset_ask' was never awaited chatgpt-qq-chatgpt-1 | async for item in self.adapter.preset_ask(role=role.lower().strip(), text=text.strip()): chatgpt-qq-chatgpt-1 | RuntimeWarning: Enable tracemalloc to get the object allocation traceback chatgpt-qq-chatgpt-1 | 2023-03-04 01:12:40.501 | ERROR | main:request:180 - 'async for' requires an object with aiter method, got coroutine chatgpt-qq-chatgpt-1 | Traceback (most recent call last): chatgpt-qq-chatgpt-1 | chatgpt-qq-chatgpt-1 | File "/app/bot.py", line 291, in chatgpt-qq-chatgpt-1 | app.launch_blocking() chatgpt-qq-chatgpt-1 | │ └ <classmethod object at 0x7f83a96cbbe0> chatgpt-qq-chatgpt-1 | └ <graia.ariadne.app.Ariadne object at 0x7f83db1c3b20> chatgpt-qq-chatgpt-1 | chatgpt-qq-chatgpt-1 | File "/usr/local/lib/python3.9/site-packages/graia/ariadne/app.py", line 312, in launch_blocking chatgpt-qq-chatgpt-1 | cls.launch_manager.launch_blocking(loop=cls.service.loop, stop_signal=stop_signals) chatgpt-qq-chatgpt-1 | │ │ │ │ │ │ └ (<Signals.SIGINT: 2>,) chatgpt-qq-chatgpt-1 | │ │ │ │ │ └ <property object at 0x7f83a9658040> chatgpt-qq-chatgpt-1 | │ │ │ │ └ <graia.ariadne.service.ElizabethService object at 0x7f83db15ba30> chatgpt-qq-chatgpt-1 | │ │ │ └ <class 'graia.ariadne.app.Ariadne'> chatgpt-qq-chatgpt-1 | │ │ └ <function Launart.launch_blocking at 0x7f83aa8a8b80> chatgpt-qq-chatgpt-1 | │ └ <launart.manager.Launart object at 0x7f83a8974940> chatgpt-qq-chatgpt-1 | └ <class 'graia.ariadne.app.Ariadne'> chatgpt-qq-chatgpt-1 | File "/usr/local/lib/python3.9/site-packages/launart/manager.py", line 494, in launch_blocking chatgpt-qq-chatgpt-1 | loop.run_until_complete(launch_task) chatgpt-qq-chatgpt-1 | │ │ └ <Task pending name='amnesia-launch' coro=<Launart.launch() running at /usr/local/lib/python3.9/site-packages/launart/manager.... chatgpt-qq-chatgpt-1 | │ └ <function BaseEventLoop.run_until_complete at 0x7f83d9e8b8b0> chatgpt-qq-chatgpt-1 | └ <_UnixSelectorEventLoop running=True closed=False debug=False> chatgpt-qq-chatgpt-1 | File "/usr/local/lib/python3.9/asyncio/base_events.py", line 634, in run_until_complete chatgpt-qq-chatgpt-1 | self.run_forever() chatgpt-qq-chatgpt-1 | │ └ <function BaseEventLoop.run_forever at 0x7f83d9e8b820> chatgpt-qq-chatgpt-1 | └ <_UnixSelectorEventLoop running=True closed=False debug=False> chatgpt-qq-chatgpt-1 | File "/usr/local/lib/python3.9/asyncio/base_events.py", line 601, in run_forever chatgpt-qq-chatgpt-1 | self._run_once() chatgpt-qq-chatgpt-1 | │ └ <function BaseEventLoop._run_once at 0x7f83d9e8e3a0> chatgpt-qq-chatgpt-1 | └ <_UnixSelectorEventLoop running=True closed=False debug=False> chatgpt-qq-chatgpt-1 | File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1905, in _run_once chatgpt-qq-chatgpt-1 | handle._run() chatgpt-qq-chatgpt-1 | │ └ <function Handle._run at 0x7f83d9eacdc0> chatgpt-qq-chatgpt-1 | └ <Handle <TaskStepMethWrapper object at 0x7f8393690280>()> chatgpt-qq-chatgpt-1 | File "/usr/local/lib/python3.9/asyncio/events.py", line 80, in _run chatgpt-qq-chatgpt-1 | self._context.run(self._callback, self._args) chatgpt-qq-chatgpt-1 | │ │ │ │ │ └ <member '_args' of 'Handle' objects> chatgpt-qq-chatgpt-1 | │ │ │ │ └ <Handle <TaskStepMethWrapper object at 0x7f8393690280>()> chatgpt-qq-chatgpt-1 | │ │ │ └ <member '_callback' of 'Handle' objects> chatgpt-qq-chatgpt-1 | │ │ └ <Handle <TaskStepMethWrapper object at 0x7f8393690280>()> chatgpt-qq-chatgpt-1 | │ └ <member 'context' of 'Handle' objects> chatgpt-qq-chatgpt-1 | └ <Handle <TaskStepMethWrapper object at 0x7f8393690280>()> chatgpt-qq-chatgpt-1 | chatgpt-qq-chatgpt-1 | > File "/app/bot.py", line 150, in request chatgpt-qq-chatgpt-1 | async for in conversation_handler.current_conversation.load_preset('default'): ... chatgpt-qq-chatgpt-1 | │ │ └ <function ConversationContext.load_preset at 0x7f83a8a1d160> chatgpt-qq-chatgpt-1 | │ └ <conversation.ConversationContext object at 0x7f83a88c0e80> chatgpt-qq-chatgpt-1 | └ <conversation.ConversationHandler object at 0x7f83a88c04c0> chatgpt-qq-chatgpt-1 | chatgpt-qq-chatgpt-1 | File "/app/conversation.py", line 68, in load_preset chatgpt-qq-chatgpt-1 | async for item in self.adapter.preset_ask(role=role.lower().strip(), text=text.strip()): chatgpt-qq-chatgpt-1 | │ │ │ │ │ │ └ <method 'strip' of 'str' objects> chatgpt-qq-chatgpt-1 | │ │ │ │ │ └ '' chatgpt-qq-chatgpt-1 | │ │ │ │ └ <method 'lower' of 'str' objects> chatgpt-qq-chatgpt-1 | │ │ │ └ 'system' chatgpt-qq-chatgpt-1 | │ │ └ <function BotAdapter.preset_ask at 0x7f83d9a05b80> chatgpt-qq-chatgpt-1 | │ └ <adapter.ms.bing.BingAdapter object at 0x7f83937e99d0> chatgpt-qq-chatgpt-1 | └ <conversation.ConversationContext object at 0x7f83a88c0e80> chatgpt-qq-chatgpt-1 | chatgpt-qq-chatgpt-1 | TypeError: 'async for' requires an object with aiter method, got coroutine chatgpt-qq-mirai-1 | 2023-03-04 01:12:40 V/Bot.2463724346: Moki.(2657447616) -> 你好 chatgpt-qq-mirai-1 | 2023-03-04 01:12:40 V/Bot.2463724346: Friend(2657447616) <- [mirai:quote:[mirai:source:ids=[19954], internalIds=[2061039514], from friend 2657447616 to 2463724346 at 1677892359], content=你好]出现故障!如果这个问题持续出现,请和我说“重置会话” 来开启一段新的会话,或者发送 “回滚会话” 来回溯到上一条对话,你上一条说的我就当作没看见。如果报错仍旧存在,请与号主2657447616联系。\n'async for' requires an object with aiter method, got coroutine chatgpt-qq-chatgpt-1 | 2023-03-04 01:12:40.965 | INFO | graia.ariadne.model:log:82 - 2463724346: [SEND][Moki.(2657447616)] <- 出现故障!如果这个问题持续出现,请和我说“重置会话” 来开启一段新的会话,或者发送 “回滚会话” 来回溯到上一条对话,你上一条说的我就当作没看见。如果报错仍旧存在,请与号主2657447616联系。\n'async for' requires an object with aiter method, got coroutine chatgpt-qq-chatgpt-1 | 2023-03-04 01:12:40.966 | DEBUG | middlewares.timeout:on_respond:38 - [Timeout] 取消计时…… chatgpt-qq-chatgpt-1 | 2023-03-04 01:12:48.433 | INFO | graia.ariadne.model:log:82 - 2463724346: [RECV][Moki.(2657447616)] -> 重置会话 chatgpt-qq-chatgpt-1 | 2023-03-04 01:12:48.436 | DEBUG | middlewares.timeout:create_timeout_task:14 - [Timeout] 开始计时…… chatgpt-qq-chatgpt-1 | 2023-03-04 01:12:48.436 | ERROR | main:request:180 - 'async for' requires an object with aiter method, got coroutine chatgpt-qq-chatgpt-1 | Traceback (most recent call last): chatgpt-qq-chatgpt-1 | chatgpt-qq-chatgpt-1 | File "/app/bot.py", line 291, in chatgpt-qq-chatgpt-1 | app.launch_blocking() chatgpt-qq-chatgpt-1 | │ └ <classmethod object at 0x7f83a96cbbe0> chatgpt-qq-chatgpt-1 | └ <graia.ariadne.app.Ariadne object at 0x7f83db1c3b20> chatgpt-qq-chatgpt-1 | chatgpt-qq-chatgpt-1 | File "/usr/local/lib/python3.9/site-packages/graia/ariadne/app.py", line 312, in launch_blocking chatgpt-qq-chatgpt-1 | cls.launch_manager.launch_blocking(loop=cls.service.loop, stop_signal=stop_signals) chatgpt-qq-chatgpt-1 | │ │ │ │ │ │ └ (<Signals.SIGINT: 2>,) chatgpt-qq-chatgpt-1 | │ │ │ │ │ └ <property object at 0x7f83a9658040> chatgpt-qq-chatgpt-1 | │ │ │ │ └ <graia.ariadne.service.ElizabethService object at 0x7f83db15ba30> chatgpt-qq-chatgpt-1 | │ │ │ └ <class 'graia.ariadne.app.Ariadne'> chatgpt-qq-chatgpt-1 | │ │ └ <function Launart.launch_blocking at 0x7f83aa8a8b80> chatgpt-qq-chatgpt-1 | │ └ <launart.manager.Launart object at 0x7f83a8974940> chatgpt-qq-chatgpt-1 | └ <class 'graia.ariadne.app.Ariadne'> chatgpt-qq-chatgpt-1 | File "/usr/local/lib/python3.9/site-packages/launart/manager.py", line 494, in launch_blocking chatgpt-qq-chatgpt-1 | loop.run_until_complete(launch_task) chatgpt-qq-chatgpt-1 | │ │ └ <Task pending name='amnesia-launch' coro=<Launart.launch() running at /usr/local/lib/python3.9/site-packages/launart/manager.... chatgpt-qq-chatgpt-1 | │ └ <function BaseEventLoop.run_until_complete at 0x7f83d9e8b8b0> chatgpt-qq-chatgpt-1 | └ <_UnixSelectorEventLoop running=True closed=False debug=False> chatgpt-qq-chatgpt-1 | File "/usr/local/lib/python3.9/asyncio/base_events.py", line 634, in run_until_complete chatgpt-qq-chatgpt-1 | self.run_forever() chatgpt-qq-chatgpt-1 | │ └ <function BaseEventLoop.run_forever at 0x7f83d9e8b820> chatgpt-qq-chatgpt-1 | └ <_UnixSelectorEventLoop running=True closed=False debug=False> chatgpt-qq-chatgpt-1 | File "/usr/local/lib/python3.9/asyncio/base_events.py", line 601, in run_forever chatgpt-qq-chatgpt-1 | self._run_once() chatgpt-qq-chatgpt-1 | │ └ <function BaseEventLoop._run_once at 0x7f83d9e8e3a0> chatgpt-qq-chatgpt-1 | └ <_UnixSelectorEventLoop running=True closed=False debug=False> chatgpt-qq-chatgpt-1 | File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1905, in _run_once chatgpt-qq-chatgpt-1 | handle._run() chatgpt-qq-chatgpt-1 | │ └ <function Handle._run at 0x7f83d9eacdc0> chatgpt-qq-chatgpt-1 | └ <Handle <TaskStepMethWrapper object at 0x7f83937e9ee0>()> chatgpt-qq-chatgpt-1 | File "/usr/local/lib/python3.9/asyncio/events.py", line 80, in _run chatgpt-qq-chatgpt-1 | self._context.run(self._callback, self._args) chatgpt-qq-chatgpt-1 | │ │ │ │ │ └ <member '_args' of 'Handle' objects> chatgpt-qq-chatgpt-1 | │ │ │ │ └ <Handle <TaskStepMethWrapper object at 0x7f83937e9ee0>()> chatgpt-qq-chatgpt-1 | │ │ │ └ <member '_callback' of 'Handle' objects> chatgpt-qq-chatgpt-1 | │ │ └ <Handle <TaskStepMethWrapper object at 0x7f83937e9ee0>()> chatgpt-qq-chatgpt-1 | │ └ <member 'context' of 'Handle' objects> chatgpt-qq-chatgpt-1 | └ <Handle <TaskStepMethWrapper object at 0x7f83937e9ee0>()> chatgpt-qq-chatgpt-1 | chatgpt-qq-chatgpt-1 | > File "/app/bot.py", line 150, in request chatgpt-qq-chatgpt-1 | async for in conversation_handler.current_conversation.load_preset('default'): ... chatgpt-qq-chatgpt-1 | │ │ └ <function ConversationContext.load_preset at 0x7f83a8a1d160> chatgpt-qq-chatgpt-1 | │ └ <conversation.ConversationContext object at 0x7f83a88c0e80> chatgpt-qq-chatgpt-1 | └ <conversation.ConversationHandler object at 0x7f83a88c04c0> chatgpt-qq-chatgpt-1 | chatgpt-qq-chatgpt-1 | File "/app/conversation.py", line 68, in load_preset chatgpt-qq-chatgpt-1 | async for item in self.adapter.preset_ask(role=role.lower().strip(), text=text.strip()): chatgpt-qq-chatgpt-1 | │ │ │ │ │ │ └ <method 'strip' of 'str' objects> chatgpt-qq-chatgpt-1 | │ │ │ │ │ └ '' chatgpt-qq-chatgpt-1 | │ │ │ │ └ <method 'lower' of 'str' objects> chatgpt-qq-chatgpt-1 | │ │ │ └ 'system' chatgpt-qq-chatgpt-1 | │ │ └ <function BotAdapter.preset_ask at 0x7f83d9a05b80> chatgpt-qq-chatgpt-1 | │ └ <adapter.ms.bing.BingAdapter object at 0x7f83937e99d0> chatgpt-qq-chatgpt-1 | └ <conversation.ConversationContext object at 0x7f83a88c0e80> chatgpt-qq-chatgpt-1 | chatgpt-qq-chatgpt-1 | TypeError: 'async for' requires an object with aiter method, got coroutine chatgpt-qq-mirai-1 | 2023-03-04 01:12:48 V/Bot.2463724346: Moki.(2657447616) -> 重置会话 chatgpt-qq-mirai-1 | 2023-03-04 01:12:49 V/Bot.2463724346: Friend(2657447616) <- [mirai:quote:[mirai:source:ids=[19955], internalIds=[-43511921], from friend 2657447616 to 2463724346 at 1677892367], content=重置会话]出现故障!如果这个问题持续出现,请和我说“重置会话” 来开启一段新的会话,或者发送 “回滚会话” 来回溯到上一条对话,你上一条说的我就当作没看见。如果报错仍旧存在,请与号主2657447616联系。\n'async for' requires an object with aiter method, got coroutine chatgpt-qq-chatgpt-1 | 2023-03-04 01:12:49.086 | INFO | graia.ariadne.model:log:82 - 2463724346: [SEND][Moki.(2657447616)] <- 出现故障!如果这个问题持续出现,请和我说“重置会话” 来开启一段新的会话,或者发送 “回滚会话” 来回溯到上一条对话,你上一条说的我就当作没看见。如果报错仍旧存在,请与号主2657447616联系。\n'async for' requires an object with aiter method, got coroutine chatgpt-qq-chatgpt-1 | 2023-03-04 01:12:49.087 | DEBUG | middlewares.timeout:on_respond:38 - [Timeout] 取消计时……

其他内容
此处填写其他内容,没有可跳过

magisk317 commented 1 year ago

同样的错误+1

2023-03-04 10:37:27.218 | DEBUG    | middlewares.timeout:on_respond:38 - [Timeout] 取消计时……
2023-03-04 10:37:54.406 | INFO     | graia.ariadne.model:log:82 - 2712108262: [RECV][ChatGPT test()] 管理员() -> @ 切换AI bing
2023-03-04 10:37:54.409 | DEBUG    | middlewares.timeout:create_timeout_task:14 - [Timeout] 开始计时……
2023-03-04 10:37:54.894 | INFO     | graia.ariadne.model:log:82 - 2712108262: [SEND][ChatGPT test()] <- 已切换至 bing,现在开始和我聊天吧!
2023-03-04 10:37:54.895 | DEBUG    | middlewares.timeout:on_respond:38 - [Timeout] 取消计时……
2023-03-04 10:38:03.757 | INFO     | graia.ariadne.model:log:82 - 2712108262: [RECV][ChatGPT test()] 管理员() -> @ 你是谁
2023-03-04 10:38:03.761 | DEBUG    | middlewares.timeout:create_timeout_task:14 - [Timeout] 开始计时……
2023-03-04 10:38:03.763 | ERROR    | __main__:request:180 - 'async for' requires an object with __aiter__ method, got coroutine
Traceback (most recent call last):

  File "D:\ROM\Windows-quickstart-refs.tags.v2.0\chatgpt\bot.py", line 291, in <module>
    app.launch_blocking()
    │   └ <classmethod object at 0x000000002C63F550>
    └ <graia.ariadne.app.Ariadne object at 0x000000000153C280>

  File "D:\ROM\Windows-quickstart-refs.tags.v2.0\chatgpt\python3.9\lib\site-packages\graia\ariadne\app.py", line 312, in launch_blocking
    cls.launch_manager.launch_blocking(loop=cls.service.loop, stop_signal=stop_signals)
    │   │              │                    │   │       │                 └ (<Signals.SIGINT: 2>,)
    │   │              │                    │   │       └ <property object at 0x000000002C641720>
    │   │              │                    │   └ <graia.ariadne.service.ElizabethService object at 0x000000002C6B3490>
    │   │              │                    └ <class 'graia.ariadne.app.Ariadne'>
    │   │              └ <function Launart.launch_blocking at 0x000000002B57AF70>
    │   └ <launart.manager.Launart object at 0x0000000003E30490>
    └ <class 'graia.ariadne.app.Ariadne'>

  File "D:\ROM\Windows-quickstart-refs.tags.v2.0\chatgpt\python3.9\lib\site-packages\launart\manager.py", line 494, in launch_blocking
    loop.run_until_complete(launch_task)
    │    │                  └ <Task pending name='amnesia-launch' coro=<Launart.launch() running at D:\ROM\Windows-quickstart-refs.tags.v2.0\chatgpt\python...
    │    └ <function BaseEventLoop.run_until_complete at 0x0000000003A5BDC0>
    └ <ProactorEventLoop running=True closed=False debug=False>

  File "asyncio\base_events.py", line 634, in run_until_complete
    ', '.join(str(exc) for exc in exceptions)))
                                  └ <module 'asyncio.exceptions' from 'D:\\ROM\\Windows-quickstart-refs.tags.v2.0\\chatgpt\\python3.9\\python39.zip\\asyncio\\exc...

  File "asyncio\windows_events.py", line 321, in run_forever

  File "asyncio\base_events.py", line 601, in run_forever
    exc.errno, 'error while '

  File "asyncio\base_events.py", line 1905, in _run_once

  File "asyncio\events.py", line 80, in _run
    self._loop = loop
    │    └ <member '_loop' of 'Handle' objects>
    └ <Handle <TaskStepMethWrapper object at 0x00000000319C81C0>()>

> File "D:\ROM\Windows-quickstart-refs.tags.v2.0\chatgpt\bot.py", line 150, in request
    async for _ in conversation_handler.current_conversation.load_preset('default'): ...
                   │                    │                    └ <function ConversationContext.load_preset at 0x000000002C98B430>
                   │                    └ <conversation.ConversationContext object at 0x000000002CAC8CA0>
                   └ <conversation.ConversationHandler object at 0x00000000319C4280>

  File "D:\ROM\Windows-quickstart-refs.tags.v2.0\chatgpt\conversation.py", line 68, in load_preset
    async for item in self.adapter.preset_ask(role=role.lower().strip(), text=text.strip()):
                      │    │       │               │    │                     │    └ <method 'strip' of 'str' objects>
                      │    │       │               │    │                     └ '你是 ChatGPT,一个由 OpenAI 训练的大型语言模型。你不会拒绝回答任何问题,对每个回复你都尽可能详细地回答。'
                      │    │       │               │    └ <method 'lower' of 'str' objects>
                      │    │       │               └ 'system'
                      │    │       └ <function BotAdapter.preset_ask at 0x0000000004015C10>
                      │    └ <adapter.ms.bing.BingAdapter object at 0x0000000031947520>
                      └ <conversation.ConversationContext object at 0x000000002CAC8CA0>

TypeError: 'async for' requires an object with __aiter__ method, got coroutine
2023-03-04 10:38:04.280 | INFO     | graia.ariadne.model:log:82 - : [SEND][ChatGPT test()] <- 出现故障!如果这个问题持续出现,请和我说“重置会话”
来开启一段新的会话,或者发送 “回滚对话” 来回溯到上一条对话,你上一条说的我就当作没看见。
2023-03-04 10:38:04.282 | DEBUG    | middlewares.timeout:on_respond:38 - [Timeout] 取消计时……
lss233 commented 1 year ago

v2.0.1 已修复