Well2333 / nonebot-plugin-bilichat

一个通过 OpenAI 来对b站视频进行总结的多功能 B站解析插件
GNU Affero General Public License v3.0
226 stars 9 forks source link

视频总结出错,请求帮助 #25

Closed HaoTian22 closed 1 year ago

HaoTian22 commented 1 year ago

请问这个应该如何解决?

04-22 20:30:57 [ERROR] nonebot_plugin_bilichat | Video(Column) av441997088 summary failed: received 1000 (OK); then sent 1000 (OK)
Traceback (most recent call last):
  File "<string>", line 21, in <module>
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\nonebot\__init__.py", line 309, in run
    get_driver().run(*args, **kwargs)
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\nonebot\drivers\fastapi.py", line 198, in run
    uvicorn.run(
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\uvicorn\main.py", line 568, in run
    server.run()
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\uvicorn\server.py", line 59, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "D:\Program Files\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "D:\Program Files\Python310\lib\asyncio\base_events.py", line 633, in run_until_complete
    self.run_forever()
  File "D:\Program Files\Python310\lib\asyncio\windows_events.py", line 321, in run_forever
    super().run_forever()
  File "D:\Program Files\Python310\lib\asyncio\base_events.py", line 600, in run_forever
    self._run_once()
  File "D:\Program Files\Python310\lib\asyncio\base_events.py", line 1896, in _run_once
    handle._run()
  File "D:\Program Files\Python310\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\nonebot\message.py", line 141, in _check_matcher
    await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\nonebot\message.py", line 187, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\nonebot\internal\matcher\matcher.py", line 753, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\nonebot\internal\matcher\matcher.py", line 728, in simple_run
    await handler(
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\nonebot\dependencies\__init__.py", line 108, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\nonebot_plugin_bilichat\__init__.py", line 140, in video_info_v11
    if summary := await summarization(cache=cache, cid=str(info["cid"])):
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\nonebot_plugin_bilichat\summary\__init__.py", line 21, in summarization
    summary, newbing_meaning = await newbing_summarization(cache, cid)
> File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\nonebot_plugin_bilichat\summary\newbing_summarise.py", line 96, in newbing_summarization
    ai_summary = await newbing_req(get_small_size_transcripts(cache.title, cache.episodes[cid].content))
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\nonebot_plugin_bilichat\summary\newbing_summarise.py", line 76, in newbing_req
    ans = await bot.ask(
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\EdgeGPT.py", line 376, in ask
    async for final, response in self.chat_hub.ask_stream(
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\EdgeGPT.py", line 310, in ask_stream
    objects = str(await self.wss.recv()).split(DELIMITER)
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\websockets\legacy\protocol.py", line 568, in recv
    await self.ensure_open()
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\websockets\legacy\protocol.py", line 944, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedOK: received 1000 (OK); then sent 1000 (OK)

另外我没太理解那个cookies到底要放在哪里,因此每个子目录应该都放了一个,配置里面也写了http代理

Well2333 commented 1 year ago

此问题是请求失败造成的,一般是网络波动造成的,你可以尝试更换更稳定的网络环境。

另外我没太理解那个cookies到底要放在哪里

你直接填写cookie文件的路径即可,例如 bilichat_newbing_cookie="/home/username/bots/cookies.json",只要程序可以以文件形式读取此文件,你放到哪里都没问题

HaoTian22 commented 1 year ago

我重试了好几次,貌似同一个视频都是同样的问题,多次平均都是网络问题的概率有点低吧?(而且我另一个bingchat的插件是能正常使用的) 还有另一些视频有以下报错

04-23 00:06:53 [ERROR] nonebot_plugin_bilichat | Video(Column) av910302758 summary failed: 'messages'
Traceback (most recent call last):
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\nonebot_plugin_bilichat\summary\__init__.py", line 21, in summarization
    summary, newbing_meaning = await newbing_summarization(cache, cid)
> File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\nonebot_plugin_bilichat\summary\newbing_summarise.py", line 96, in newbing_summarization
    ai_summary = await newbing_req(get_small_size_transcripts(cache.title, cache.episodes[cid].content))
  File "D:\code\bot\nonebot\Hao_Tian_Bot\.venv\lib\site-packages\nonebot_plugin_bilichat\summary\newbing_summarise.py", line 83, in newbing_req
    bing_resp: Dict = ans["item"]["messages"][1]
KeyError: 'messages'
Well2333 commented 1 year ago

我重试了好几次,貌似同一个视频都是同样的问题,多次平均都是网络问题的概率有点低吧?(而且我另一个bingchat的插件是能正常使用的)

因为需要将视频的字幕也传输过去,正常情况下使用newbing的请求大小远低于此插件的请求大小,而且你第一个测试的视频 av441997088 是一个长达40分钟的视频,其文本量可能会超过1万字。 如果同一个视频反复出错仍然考虑是你的网络质量有问题,或是超出了newbing能容纳的上限(但具体是多少未知),你可以考虑设置 bilichat_newbing_token_limit 为一个较低的数值以降低网络的影响。

还有另一些视频有以下报错

此处也可能是解析错误,如果能够复现的话,可以将 loglevel 设置为 DEBUG 或更低,这样就能看到 newbing 完整的返回信息了。在没有这部分信息之前我也无法做出进一步推论和bug修复。

HaoTian22 commented 1 year ago

哦,我大概理解了,尝试生成几分钟(3000char)的视频依然需要花费近2分钟的时间,通过比对时间发现,我以上错误貌似都发生在请求的5秒之内,超过5秒没问题的那大概率是成功了的,谢谢你的帮助 至于具体网络什么因素导致的,可能我还得要进一步研究(这个连DEBUG都提供没什么有用的信息)

Well2333 commented 1 year ago

哦,我大概理解了,尝试生成几分钟(3000char)的视频依然需要花费近2分钟的时间,通过比对时间发现,我以上错误貌似都发生在请求的5秒之内,超过5秒没问题的那大概率是成功了的,谢谢你的帮助

是的,当场就能生成回答的大概率就是newbing把会话掐了,需要一定时间的是通过审核且正在查询的。

至于具体网络什么因素导致的,可能我还得要进一步研究(这个连DEBUG都提供没什么有用的信息)

debug中的信息是有用的,在报错前的最后一条就应该是bing返回的信息,我需要这个信息来判断是不是有新的返回格式,或者现在的解析是否出现问题了

HaoTian22 commented 1 year ago

不,在出错的情况下,error的上面是

04-23 07:22:30 [INFO] nonebot_plugin_bilichat | Generation summary of Video(Column) av441997088
04-23 07:22:30 [DEBUG] nonebot_plugin_bilichat | prompt have 13518 chars
04-23 07:22:30 [DEBUG] nonebot_plugin_bilichat | an error has occurred, but sentry_sdk is not installed
04-23 07:22:30 [ERROR] nonebot_plugin_bilichat | Video(Column) av527087544 summary failed: sent 1000 (OK); then received 1000 (OK)

意味着貌似bing直接没有返回?

Well2333 commented 1 year ago

不,在出错的情况下,error的上面是

04-23 07:22:30 [INFO] nonebot_plugin_bilichat | Generation summary of Video(Column) av441997088
04-23 07:22:30 [DEBUG] nonebot_plugin_bilichat | prompt have 13518 chars
04-23 07:22:30 [DEBUG] nonebot_plugin_bilichat | an error has occurred, but sentry_sdk is not installed
04-23 07:22:30 [ERROR] nonebot_plugin_bilichat | Video(Column) av527087544 summary failed: sent 1000 (OK); then received 1000 (OK)

意味着貌似bing直接没有返回?

呃呃,我要的是你keyerror的那个报错的回复啊,你这个我已经解释过了是文本量过长了。

HaoTian22 commented 1 year ago

那个我貌似今天都没出现过了,等哪天再见到我再发吧