Git Product home page Git Product logo

nonebot-plugin-chatgpt's Introduction

NoneBotPluginLogo

NoneBotPluginText

nonebot-plugin-chatgpt

✨ ChatGPT AI 对话 ✨

license pypi python

📖 介绍

智能对话聊天插件。

💿 安装

使用 nb-cli 安装 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-chatgpt
使用包管理器安装 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
pip
pip install nonebot-plugin-chatgpt
pdm
pdm add nonebot-plugin-chatgpt
poetry
poetry add nonebot-plugin-chatgpt
conda
conda install nonebot-plugin-chatgpt

打开 nonebot2 项目的 bot.py 文件, 在其中写入

nonebot.load_plugin('nonebot_plugin_chatgpt')

⚙️ 配置

在 nonebot2 项目的 .env 文件中添加下表中的必填配置(在 ARM 平台,可能必须使用 CHATGPT_SESSION_TOKEN 登录)

⚠️ Windows 系统下需要在 .env.dev 文件中设置 FASTAPI_RELOAD=false

配置项 必填 默认值 说明
CHATGPT_SESSION_TOKEN 空字符串 ChatGPT 的 session_token,如配置则优先使用
CHATGPT_ACCOUNT 空字符串 ChatGPT 登陆邮箱,未配置则使用 session_token
CHATGPT_PASSWORD 空字符串 ChatGPT 登陆密码,未配置则使用 session_token
CHATGPT_CD_TIME 60 冷却时间,单位:秒
CHATGPT_PROXIES None 代理地址,格式为: http://ip:port
CHATGPT_REFRESH_INTERVAL 30 session_token 自动刷新间隔,单位:分钟
CHATGPT_COMMAND 空字符串 触发聊天的命令,可以是 字符串 或者 字符串列表
如果为空字符串或者空列表,则默认响应全部消息
CHATGPT_TO_ME True 是否需要@机器人
CHATGPT_TIMEOUT 30 请求服务器的超时时间,单位:秒
CHATGPT_API https://chat.openai.com/ API 地址,可配置反代
CHATGPT_IMAGE False 是否以图片形式发送。
如果无法显示文字,请点击此处查看解决办法
CHATGPT_IMAGE_WIDTH 500 消息图片宽度,单位:像素
CHATGPT_PRIORITY 999 事件响应器优先级
CHATGPT_BLOCK True 是否阻断消息传播
CHATGPT_PRIVATE True 是否允许私聊使用
CHATGPT_SCOPE private 设置公共会话或私有会话
private:私有会话,群内成员会话各自独立
public:公共对话,群内成员共用同一会话
CHATGPT_DATA 插件目录下 插件数据保存目录的路径
CHATGPT_MAX_ROLLBACK 5 设置最多支持回滚多少会话
CHATGPT_DETAILED_ERROR False 是否允许输出详细错误信息

获取 session_token

  1. 登录 https://chat.openai.com/chat,并点掉所有弹窗
  2. F12 打开控制台
  3. 切换到 Application/应用 选项卡,找到 Cookies
  4. 复制 __Secure-next-auth.session-token 的值,配置到 CHATGPT_SESSION_TOKEN 即可

image

🎉 使用

默认配置下,@机器人加任意文本即可。

如果需要修改插件的触发方式,自定义 CHATGPT_COMMANDCHATGPT_TO_ME 配置项即可。

指令 需要@ 范围 说明
刷新会话/刷新对话 群聊/私聊 重置会话记录,开始新的对话
导出会话/导出对话 群聊/私聊 导出当前会话记录
导入会话/导入对话 + 会话ID + 父消息ID(可选) 群聊/私聊 将会话记录导入,这会替换当前的会话
保存会话/保存对话 + 会话名称 群聊/私聊 将当前会话保存
查看会话/查看对话 群聊/私聊 查看已保存的所有会话
切换会话/切换对话 + 会话名称 群聊/私聊 切换到指定的会话
回滚会话/回滚对话 群聊/私聊 返回到之前的会话,输入数字可以返回多个会话,但不可以超过最大支持数量

🤝 贡献

🎉 鸣谢

感谢以下开发者对该项目做出的贡献:

nonebot-plugin-chatgpt's People

Contributors

a-kirami avatar caesius-tim avatar hv0905 avatar jerry-fage avatar sena-nana avatar uiharuayako avatar zeithrold avatar zhulinyv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nonebot-plugin-chatgpt's Issues

[Feature]: 可以更新一下主页的使用方法吗

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

可以更新一下主页的使用方法吗,按照原来那个方法配置还是会有issues中的那个tag错误

您想要的解决方案

404

您考虑过的替代方案

404

实现的功能是什么样的?

404

还有什么要补充的吗?

404

[Feature]: 加入储存数据并在重启后自动读取的功能

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

目前,每次机器人重启后,之前保存的会话数据,cookie数据都会丢失,而此时config文档中的cookie也已经过期了,这就需要再重新获取cookie很麻烦

您想要的解决方案

每次刷新会话时,将当前的cookie保存至json文件,在下一次启动时,读取json文件的cookie,优先用已保存的cookie,无效再取设置,再无效就抛出错误。

需要在刷新会话的部分加入保存数据的逻辑,并在初始化config的部分加入读取数据的逻辑

您考虑过的替代方案

No response

实现的功能是什么样的?

No response

还有什么要补充的吗?

No response

[BUG]: 12月15日windows端的智能聊天插件出现 问题,询问机器人时,机器人回复请求过多,请放慢速度,无法正常使用,昨天很正常。

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

v0.7.1

问题描述

[BUG]: 12月15日windows端的智能聊天插件出现 问题,询问机器人时,机器人回复请求过多,请放慢速度,无法正常使用,昨天很正常。

复现步骤

可能是chatgpt更新了新的保护措施

预期行为

No response

实际行为

No response

日志信息

No response

额外补充

No response

[BUG]:

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

0.7.1

问题描述

总是报错token失效,昨天第一次安装此插件,正常使用,今天下午在报错一次token失效后,无论如何更换token,都是答复token失效,请重新设置token

复现步骤

1chatgpt获取token2填写到env配置文件3启动机器人4@机器人并随便讲话

预期行为

正常回复

实际行为

token失效,请重新设置token

日志信息

296~NV}Q7YK29)N9RM0LN38
R@T%SW(19K }FPHU`0GUPCR
并没有发现什么异常的地方

额外补充

No response

能写一个关键词触发吗

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

我通过yunzai机器人,使用py-plugin插件来达到运行nb2的插件,但是由于没有关键词触发,导致了所说的每一句话都能够触发回复。

您想要的解决方案

请求添加一个触发指令。

您考虑过的替代方案

No response

实现的功能是什么样的?

No response

还有什么要补充的吗?

No response

[BUG]: __Secure-next-auth.session-token会在当前浏览页面失去焦点时自动更改

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

0.7.0

问题描述

image
开启系统代理(日本节点,并没有使用CHATGPT_PROXIES)的情况下,只要当前页面失去焦点,_Secure-next-auth.session-token就会变化,对应到插件中就是无限获取
image
在关闭系统代理之后,网页也是一样的情况,只不过插件那边的情况有所不同
image
image

最总导致的结果就是无法正常使用插件
image
但是昨天我测试的时候还是可以正常使用,只不过使用的是当时还未合并的分支#52
不过应该跟这个关系不大。
不知道是不是跟账号本身有关系?

复现步骤

https://chat.openai.com/chat
上面的页面失去焦点,就会导致__Secure-next-auth.session-token变化

预期行为

No response

实际行为

No response

日志信息

No response

额外补充

No response

[BUG]: 启动报错TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

0.1.0

问题描述

启动报错,无法运行插件

复现步骤

1、ubuntu20.04,python3.9.15,nonebot2==2.0.0b5
2、在src.plugins.下git clone
3、根据readme填写TOKEN
4、启动nb端

预期行为

正常启动

实际行为

报错,无法正常启动

日志信息

image

额外补充

No response

[Feature]: 希望能出手动刷新配置文件sessiontoken的命令

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

有时token并不能自动刷新,会导致一天后出现HTTP401 token过期错误。
希望能够出命令,手动刷新属于chatgpt的配置文件中session token的值

您想要的解决方案

如上

您考虑过的替代方案

No response

实现的功能是什么样的?

No response

还有什么要补充的吗?

No response

[BUG]: RuntimeError: Cannot load plugin "nonebot_plugin_htmlrender"!

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

当前最新版本

问题描述

无法读取 "nonebot_plugin_htmlrender"!

复现步骤

和之前一样手动覆盖和安装,出现启动报错。

预期行为

No response

实际行为

No response

日志信息

、Traceback (most recent call last):
File "/home/bot/zhenxun_bot/bot.py", line 16, in
nonebot.load_plugins("my_plugins")
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/nonebot/plugin/load.py", line 45, in load_plugins
return manager.load_all_plugins()
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/nonebot/plugin/manager.py", line 168, in load_all_plugins
return set(
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/nonebot/plugin/manager.py", line 169, in
filter(None, (self.load_plugin(name) for name in self.available_plugins))
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/nonebot/plugin/manager.py", line 145, in load_plugin
module = importlib.import_module(
File "/usr/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/nonebot/plugin/manager.py", line 233, in exec_module
super().exec_module(module)
File "", line 850, in exec_module
File "", line 228, in _call_with_frames_removed
File "/home/bot/zhenxun_bot/my_plugins/nonebot_plugin_chatgpt/init.py", line 22, in
require("nonebot_plugin_htmlrender")
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/nonebot/plugin/load.py", line 165, in require
plugin = load_plugin(name)
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/nonebot/plugin/load.py", line 34, in load_plugin
return manager.load_plugin(module_path)

File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/nonebot/plugin/manager.py", line 155, in load_plugin
raise RuntimeError(
RuntimeError: Module nonebot_plugin_htmlrender is not loaded as a plugin! Make sure not to import it before loading.
12-14 00:08:44 [ERROR] nonebot | Failed to import "nonebot_plugin_chatgpt"
Traceback (most recent call last):
File "/home/bot/zhenxun_bot/bot.py", line 16, in
nonebot.load_plugins("my_plugins")
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/nonebot/plugin/load.py", line 45, in load_plugins
return manager.load_all_plugins()
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/nonebot/plugin/manager.py", line 168, in load_all_plugins
return set(
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/nonebot/plugin/manager.py", line 169, in
filter(None, (self.load_plugin(name) for name in self.available_plugins))
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/nonebot/plugin/manager.py", line 145, in load_plugin
module = importlib.import_module(
File "/usr/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/nonebot/plugin/manager.py", line 233, in exec_module
super().exec_module(module)
File "", line 850, in exec_module
File "", line 228, in _call_with_frames_removed
File "/home/bot/zhenxun_bot/my_plugins/nonebot_plugin_chatgpt/init.py", line 22, in
require("nonebot_plugin_htmlrender")
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/nonebot/plugin/load.py", line 167, in require
raise RuntimeError(f'Cannot load plugin "{name}"!')
RuntimeError: Cannot load plugin "nonebot_plugin_htmlrender"!

额外补充

No response

[Feature]:大佬你好,有一些回复比较长可以做成图片回复吗?

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

,有一些回复比较长可以做成图片回复吗?

您想要的解决方案

QQ图片20221206124214
把回复做成上图中这样

您考虑过的替代方案

No response

实现的功能是什么样的?

No response

还有什么要补充的吗?

No response

[BUG]: 简单提问如何刷新会话

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

0.4.1

问题描述

请问一下,在开启nonebot命令前缀为.
chatgpt前缀为&
chatgpt_to_me=false
的前提下,如何刷新会话?感谢!(排列组合了半天没试出来)

复现步骤

预期行为

No response

实际行为

No response

日志信息

No response

额外补充

No response

[BUG]: 图片不全

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

0.4.0

问题描述

以图片形式输出,当其中出现代码的时候,就会超出图片大小,从而无法显示

复现步骤

向bot提出一个问题,使其回复中包含代码

预期行为

完整的输出

实际行为

image

日志信息

No response

额外补充

No response

[BUG]: 回滚会话出现错误(AttributeError: 'str' object has no attribute 'user_id')

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

nonebot-plugin-chatgpt-0.7.0 Python3.9.13

问题描述

在执行回滚对话时报错

复现步骤

在会话中执行回滚会话指令

预期行为

回滚会话

实际行为

No response

日志信息

12-14 15:32:08 [ERROR] nonebot | Running Matcher(type='message', module=nonebot_plugin_chatgpt) failed.
Traceback (most recent call last):
File "e:\nb2tur\bot_test\Kou\bot.py", line 57, in
nonebot.run(app="mp_main:app")
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\site-packages\nonebot_init_.py", line 273, in run
get_driver().run(*args, **kwargs)
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\site-packages\nonebot\drivers\fastapi.py", line 172, in run
uvicorn.run(
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\site-packages\uvicorn\main.py", line 569, in run
server.run()
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\site-packages\uvicorn\server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 634, in run_until_complete
self.run_forever()
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 321, in run_forever
super().run_forever()
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 601, in run_forever
self._run_once()
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 1905, in _run_once
handle._run()
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\site-packages\nonebot\message.py", line 142, in _check_matcher
await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)

File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\site-packages\nonebot\message.py", line 188, in run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\site-packages\nonebot\internal\matcher\matcher.py", line 727, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\site-packages\nonebot\internal\matcher\matcher.py", line 702, in simple_run
await handler(
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\site-packages\nonebot\dependencies_init
.py", line 108, in call
return await cast(Callable[..., Awaitable[R]], self.call)(**values)
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\site-packages\nonebot_plugin_chatgpt_init_.py", line 179, in rollback_conversation
count=session.count(event)
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\site-packages\nonebot_plugin_chatgpt\utils.py", line 131, in count
return self[sid]["conversation_id"].count()
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\site-packages\nonebot_plugin_chatgpt\utils.py", line 75, in getitem
return super().getitem(self.id(event))
File "C:\Users\Ara\AppData\Local\Programs\Python\Python39\lib\site-packages\nonebot_plugin_chatgpt\utils.py", line 112, in id
event.group_id if isinstance(event, GroupMessageEvent) else event.user_id
AttributeError: 'str' object has no attribute 'user_id'

额外补充

image
image
image

[Feature]: 希望公共会话模式加入su权限以及部分设置项可用命令修改

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

将su权限添加至公共会话操作中,即su非群管也能在公共会话模式下操作导入会话等操作,配置项方面比如超时时长,公共和私有会话切换这类改成可用命令修改会方便很多

您想要的解决方案

1

您考虑过的替代方案

No response

实现的功能是什么样的?

No response

还有什么要补充的吗?

No response

[BUG]: asyncio抛出NotImplementedError

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

37a43bf

问题描述

使用pip install --upgrade,升级插件,之后抛出异常,尝试卸载插件使用脚手架安装未解决,感觉可能是依赖版本不对?

复现步骤

安装插件后报错,屏蔽插件之后nonebot正常启动。

预期行为

nonebot正常启动

实际行为

nonebot炸了

日志信息

`12-14 10:22:16 [INFO] nonebot_plugin_apscheduler | Scheduler Started
Task exception was never retrieved
future: <Task finished name='Task-3' coro=<Connection.run() done, defined at C:\Users\Administrator\AppData\Local\Progra
ms\Python\Python310\lib\site-packages\playwright_impl_connection.py:240> exception=NotImplementedError()>
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\playwright_impl_connection.py
", line 247, in run
await self._transport.connect()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\playwright_impl_transport.py"
, line 132, in connect
raise exc
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\playwright_impl_transport.py"
, line 120, in connect
self._proc = await asyncio.create_subprocess_exec(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\asyncio\subprocess.py", line 218, in create_s
ubprocess_exec
transport, protocol = await loop.subprocess_exec(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 1667, in subpro
cess_exec
transport = await self._make_subprocess_transport(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 498, in _make_s
ubprocess_transport
raise NotImplementedError
NotImplementedError
12-14 10:22:16 [ERROR] uvicorn | Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\starlette\routing.py", line 671
, in lifespan
async with self.lifespan_context(app):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\starlette\routing.py", line 566
, in aenter
await self.router.startup()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\starlette\routing.py", line 648
, in startup
await handler()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot_plugin_htmlrender_ini
t
.py", line 25, in init
browser = await get_browser(**kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot_plugin_htmlrender\brows
er.py", line 60, in get_browser
return _browser or await init(**kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot_plugin_htmlrender\brows
er.py", line 36, in init
_playwright = await async_playwright().start()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\playwright\async_api_context_m
anager.py", line 51, in start
return await self.aenter()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\playwright\async_api_context_m
anager.py", line 46, in aenter
playwright = AsyncPlaywright(next(iter(done)).result())
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\playwright_impl_transport.py"
, line 120, in connect
self._proc = await asyncio.create_subprocess_exec(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\asyncio\subprocess.py", line 218, in create_s
ubprocess_exec
transport, protocol = await loop.subprocess_exec(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 1667, in subpro
cess_exec
transport = await self._make_subprocess_transport(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 498, in _make_s
ubprocess_transport
raise NotImplementedError
NotImplementedError

12-14 10:22:16 [ERROR] uvicorn | Application startup failed. Exiting.`

额外补充

版本信息:
程序:
python V3.10.7
nonebot 2.0.0rc2
nonebot-adapter-cqhttp 2.0.0b1
依赖:
asyncio 3.4.3
playwright 1.28.0
starlette 0.22.0
nonebot_plugin_htmlrender 0.2.0.1
No response

[BUG]: 请问是不是只支持onebot v11传来的消息?其他适配器传来消息会被skipped?

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

0.6.0

问题描述

使用adapter-ntchat+ntchat-client可以收到消息,而且会被handler处理,但是会skipped。。
log如下:

12-11 18:18:47 [SUCCESS] nonebot | ntchat wxid_7e62t4v31ne322 | [MT_RECV_TEXT_MSG]: Message 9024582476765405967 from Run: //0728hello
12-11 18:18:47 [DEBUG] nonebot | Checking for matchers in priority 1...
12-11 18:18:47 [DEBUG] nonebot | Checking for matchers in priority 10...
12-11 18:18:47 [DEBUG] nonebot | Checking for matchers in priority 999...
12-11 18:18:47 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot_plugin_chatgpt.utils)
12-11 18:18:47 [DEBUG] nonebot | Running Matcher(type='message', module=nonebot_plugin_chatgpt.utils)
12-11 18:18:47 [DEBUG] nonebot | Running handler Dependent(call=ai_chat, parameterless=(Depends(Dependent(call=check_cooldown)),))
12-11 18:18:47 [DEBUG] nonebot | Handler Dependent(call=ai_chat, parameterless=(Depends(Dependent(call=check_cooldown)),)) skipped
12-11 18:18:47 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_chatgpt.utils) running complete
12-11 18:18:47 [DEBUG] nonebot | Stop event propagation

复现步骤

1.NB2里安装了ntchat适配器nb adapter install nonebot-adapter-ntchat
2.下载了ntchat-client并启动,可以在NB2里收到消息
3.收到消息且触发了handler,但会被skipped

(使用onebot v11收到的消息可以正常处理,不会被skipped)

预期行为

No response

实际行为

No response

日志信息

12-11 18:18:47 [SUCCESS] nonebot | ntchat wxid_7e62t4v31ne322 | [MT_RECV_TEXT_MSG]: Message 9024582476765405967 from Run: //0728hello
12-11 18:18:47 [DEBUG] nonebot | Checking for matchers in priority 1...
12-11 18:18:47 [DEBUG] nonebot | Checking for matchers in priority 10...
12-11 18:18:47 [DEBUG] nonebot | Checking for matchers in priority 999...
12-11 18:18:47 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot_plugin_chatgpt.utils)
12-11 18:18:47 [DEBUG] nonebot | Running Matcher(type='message', module=nonebot_plugin_chatgpt.utils)
12-11 18:18:47 [DEBUG] nonebot | Running handler Dependent(call=ai_chat, parameterless=(Depends(Dependent(call=check_cooldown)),))
12-11 18:18:47 [DEBUG] nonebot | Handler Dependent(call=ai_chat, parameterless=(Depends(Dependent(call=check_cooldown)),)) skipped
12-11 18:18:47 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_chatgpt.utils) running complete
12-11 18:18:47 [DEBUG] nonebot | Stop event propagation

额外补充

No response

[BUG]: post 请求异常

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

latest

问题描述

status_code:503 text:<style type='text/css'>body {font-family:Arial; margin-left:40px; }img { border:0 none; }#content { margin-left: auto; margin-right: auto }#message h2 { font-size: 20px; font-weight: normal; color: #000000; margin: 34px 0px 0px 0px }#message p { font-size: 13px; color: #000000; margin: 7px 0px 0px0px}#errorref { font-size: 11px; color: #737373; margin-top: 41px }</style><title>Service unavailable</title>

Our services aren't available right now

We're working to restore all services as soon as possible. Please check back soon.

04kWQYwAAAABjzQe+L42PRa2ge0NGN3OdSEtCRURHRTA3MTUAZTY2YjhiMDMtMDc5My00NDA5LTk3NzMtMmU2MTJlNzFhMWUz

复现步骤

post 请求异常

预期行为

No response

实际行为

No response

日志信息

No response

额外补充

No response

[Feature]: 希望能通过指令来重置线程

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

chatgpt的每次对话好像都有不同的随机值,对AI进行描述设定的时候有时候会遵守设定有时候则不会,
比如:从现在开始,你是一个资深游戏玩家。

设定成功会回答:很高兴能够成为一名资深游戏玩家。作为一名资深玩家。。。。
设定不成功会回答:很高兴能够为您提供帮助,不过我不是人类,而是一个人工智能助手。。。

希望大佬有机会能考虑加一个“重置线程”功能,感谢

您想要的解决方案

您考虑过的替代方案

实现的功能是什么样的?

还有什么要补充的吗?

[BUG]: 超时

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

0.7.2

问题描述

向机器人发起对话,机器人不回应,终端报错超时

复现步骤

1启动机器人2向机器人发起对话

预期行为

正常回复

实际行为

机器人不回应,终端发生报错

日志信息

7WIK N0C2T`XL6 HHPOBA2E

额外补充

No response

[Feature]: 添加多cookies或多账号请求功能

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

在使用过程中,由于只有一个cookies登录存在,在请求量大时存在响应速度慢,请求可能失败的问题。

您想要的解决方案

基于以上问题,添加一个模块,在维护会话不过期的同时尽可能的将nonebot的请求分散到多个cookies上。使其总承载能力提高。

您考虑过的替代方案

除非经过权限特许,否则模块在回答之前应该先由请求者完善cookies信息。或者添加相关的设置,使得特定群组的请求应该满足以上所述条件。

实现的功能是什么样的?

添加一个cookies维系模块,或在设置中添加群组设置相关内容。

还有什么要补充的吗?

No response

[BUG]: 频繁请求可能会导致 httpcore.ReadTimeout

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

0.1.1

问题描述

在以大约数秒(<10)的速度调用该插件一段时间之后,会出现 httpcore.ReadTimeout 报错

复现步骤

在以大约数秒(<10)的速度调用该插件

预期行为

No response

实际行为

No response

日志信息

12-05 14:05:05 [ERROR] nonebot | Running Matcher(type='message', module=plugins.nonebot_plugin_chatgpt) failed.
Traceback (most recent call last):

  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/anyio/streams/tls.py", line 130, in _call_sslobject_method
    result = func(*args)
             │     └ (65536,)
             └ <bound method SSLObject.read of <ssl.SSLObject object at 0x7fe3fd8c7280>>
  File "/usr/lib/python3.10/ssl.py", line 917, in read
    v = self._sslobj.read(len)
        │    │       │    └ 65536
        │    │       └ <method 'read' of '_ssl._SSLSocket' objects>
        │    └ <_ssl._SSLSocket object at 0x7fe422088200>
        └ <ssl.SSLObject object at 0x7fe3fd8c7280>

ssl.SSLWantReadError: The operation did not complete (read) (_ssl.c:2548)


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpcore/backends/asyncio.py", line 33, in read
    return await self._stream.receive(max_bytes=max_bytes)
                 │    │       │                 └ 65536
                 │    │       └ <function TLSStream.receive at 0x7fe421ef3370>
                 │    └ TLSStream(transport_stream=<anyio._backends._asyncio.SocketStream object at 0x7fe3fd8c6290>, standard_compatible=False, _ssl_...
                 └ <httpcore.backends.asyncio.AsyncIOStream object at 0x7fe3fd8c69e0>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/anyio/streams/tls.py", line 195, in receive
    data = await self._call_sslobject_method(self._ssl_object.read, max_bytes)
                 │    │                      │    │           │     └ 65536
                 │    │                      │    │           └ <function SSLObject.read at 0x7fe424590310>
                 │    │                      │    └ <ssl.SSLObject object at 0x7fe3fd8c7280>
                 │    │                      └ TLSStream(transport_stream=<anyio._backends._asyncio.SocketStream object at 0x7fe3fd8c6290>, standard_compatible=False, _ssl_...
                 │    └ <function TLSStream._call_sslobject_method at 0x7fe421ef31c0>
                 └ TLSStream(transport_stream=<anyio._backends._asyncio.SocketStream object at 0x7fe3fd8c6290>, standard_compatible=False, _ssl_...
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/anyio/streams/tls.py", line 137, in _call_sslobject_method
    data = await self.transport_stream.receive()
                 │    │                └ <function SocketStream.receive at 0x7fe401d00d30>
                 │    └ <anyio._backends._asyncio.SocketStream object at 0x7fe3fd8c6290>
                 └ TLSStream(transport_stream=<anyio._backends._asyncio.SocketStream object at 0x7fe3fd8c6290>, standard_compatible=False, _ssl_...
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 1265, in receive
    await self._protocol.read_event.wait()
          │    │         │          └ <function Event.wait at 0x7fe423ec2a70>
          │    │         └ <asyncio.locks.Event object at 0x7fe3fd8c5b70 [set]>
          │    └ <anyio._backends._asyncio.StreamProtocol object at 0x7fe3fd8c4730>
          └ <anyio._backends._asyncio.SocketStream object at 0x7fe3fd8c6290>
  File "/usr/lib/python3.10/asyncio/locks.py", line 214, in wait
    await fut
          └ <Future cancelled>

asyncio.exceptions.CancelledError


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpcore/_exceptions.py", line 8, in map_exceptions
    yield
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpcore/backends/asyncio.py", line 31, in read
    with anyio.fail_after(timeout):
         │     │          └ 10
         │     └ <function fail_after at 0x7fe421ebd900>
         └ <module 'anyio' from '/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/anyio/...
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/anyio/_core/_tasks.py", line 118, in __exit__
    raise TimeoutError

TimeoutError


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
    yield
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
    resp = await self._pool.handle_async_request(req)
                 │    │     │                    └ <Request [b'POST']>
                 │    │     └ <function AsyncConnectionPool.handle_async_request at 0x7fe421a28af0>
                 │    └ <httpcore.AsyncConnectionPool object at 0x7fe3fd8c7d90>
                 └ <httpx.AsyncHTTPTransport object at 0x7fe3fd8c6b60>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 253, in handle_async_request
    raise exc
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 237, in handle_async_request
    response = await connection.handle_async_request(request)
                     │          │                    └ <Request [b'POST']>
                     │          └ <function AsyncHTTPConnection.handle_async_request at 0x7fe421a1bd90>
                     └ <AsyncHTTPConnection ['https://chat.openai.com:443', HTTP/1.1, CLOSED, Request Count: 1]>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpcore/_async/connection.py", line 90, in handle_async_request
    return await self._connection.handle_async_request(request)
                 │    │           │                    └ <Request [b'POST']>
                 │    │           └ <function AsyncHTTP11Connection.handle_async_request at 0x7fe421a1a9e0>
                 │    └ <AsyncHTTP11Connection ['https://chat.openai.com:443', CLOSED, Request Count: 1]>
                 └ <AsyncHTTPConnection ['https://chat.openai.com:443', HTTP/1.1, CLOSED, Request Count: 1]>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpcore/_async/http11.py", line 105, in handle_async_request
    raise exc
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpcore/_async/http11.py", line 84, in handle_async_request
    ) = await self._receive_response_headers(**kwargs)
              │    │                           └ {'request': <Request [b'POST']>}
              │    └ <function AsyncHTTP11Connection._receive_response_headers at 0x7fe421a1b400>
              └ <AsyncHTTP11Connection ['https://chat.openai.com:443', CLOSED, Request Count: 1]>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpcore/_async/http11.py", line 148, in _receive_response_headers
    event = await self._receive_event(timeout=timeout)
                  │    │                      └ 10
                  │    └ <function AsyncHTTP11Connection._receive_event at 0x7fe421a1b520>
                  └ <AsyncHTTP11Connection ['https://chat.openai.com:443', CLOSED, Request Count: 1]>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpcore/_async/http11.py", line 177, in _receive_event
    data = await self._network_stream.read(
                 │    │               └ <function AsyncIOStream.read at 0x7fe401d03520>
                 │    └ <httpcore.backends.asyncio.AsyncIOStream object at 0x7fe3fd8c69e0>
                 └ <AsyncHTTP11Connection ['https://chat.openai.com:443', CLOSED, Request Count: 1]>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpcore/backends/asyncio.py", line 30, in read
    with map_exceptions(exc_map):
         │              └ {<class 'TimeoutError'>: <class 'httpcore.ReadTimeout'>, <class 'anyio.BrokenResourceError'>: <class 'httpcore.ReadError'>}
         └ <function map_exceptions at 0x7fe4219f0af0>
  File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
    │    │   │     │    │      └ <traceback object at 0x7fe402030080>
    │    │   │     │    └ TimeoutError()
    │    │   │     └ <class 'TimeoutError'>
    │    │   └ <method 'throw' of 'generator' objects>
    │    └ <generator object map_exceptions at 0x7fe3ff9feb20>
    └ <contextlib._GeneratorContextManager object at 0x7fe3fc3f2e60>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
    raise to_exc(exc)
          └ <class 'httpcore.ReadTimeout'>

httpcore.ReadTimeout


The above exception was the direct cause of the following exception:


Traceback (most recent call last):

  File "/home/jason/zhenxun_bot/bot.py", line 21, in <module>
    nonebot.run()
    │       └ <function run at 0x7fe422e85f30>
    └ <module 'nonebot' from '/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/none...

  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/nonebot/__init__.py", line 273, in run
    get_driver().run(*args, **kwargs)
    │                 │       └ {}
    │                 └ ()
    └ <function get_driver at 0x7fe42471d090>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 172, in run
    uvicorn.run(
    │       └ <function run at 0x7fe421e3f640>
    └ <module 'uvicorn' from '/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/uvic...
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/uvicorn/main.py", line 576, in run
    server.run()
    │      └ <function Server.run at 0x7fe421e3f7f0>
    └ <uvicorn.server.Server object at 0x7fe4022d35b0>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/uvicorn/server.py", line 60, in run
    return asyncio.run(self.serve(sockets=sockets))
           │       │   │    │             └ None
           │       │   │    └ <function Server.serve at 0x7fe421e3f880>
           │       │   └ <uvicorn.server.Server object at 0x7fe4022d35b0>
           │       └ <function run at 0x7fe4244dbc70>
           └ <module 'asyncio' from '/usr/lib/python3.10/asyncio/__init__.py'>
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
           │    │                  └ <coroutine object Server.serve at 0x7fe4022f63b0>
           │    └ <method 'run_until_complete' of 'uvloop.loop.Loop' objects>
           └ <uvloop.Loop running=True closed=False debug=False>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/nonebot/message.py", line 142, in _check_matcher
    await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
          │            │        │    │      │      │      └ {<function _command at 0x7fe422ea4c10>: <Task finished name='Task-148474' coro=<_command() done, defined at /home/jason/.cach...
          │            │        │    │      │      └ <contextlib.AsyncExitStack object at 0x7fe3fc4cdc30>
          │            │        │    │      └ {'_prefix': {'command': None, 'raw_command': None, 'command_arg': None, 'command_start': None}}
          │            │        │    └ GroupMessageEvent(time=1670249093, self_id=2037909602, post_type='message', sub_type='normal', user_id=[qq_id], message_ty...
          │            │        └ Bot(type='OneBot V11', self_id='2037909602')
          │            └ Matcher(type='message', module=plugins.nonebot_plugin_chatgpt)
          └ <function _run_matcher at 0x7fe422da2200>
> File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/nonebot/message.py", line 186, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
          │       │   │    │      │      │      └ {<function _command at 0x7fe422ea4c10>: <Task finished name='Task-148474' coro=<_command() done, defined at /home/jason/.cach...
          │       │   │    │      │      └ <contextlib.AsyncExitStack object at 0x7fe3fc4cdc30>
          │       │   │    │      └ {'_prefix': {'command': None, 'raw_command': None, 'command_arg': None, 'command_start': None}}
          │       │   │    └ GroupMessageEvent(time=1670249093, self_id=2037909602, post_type='message', sub_type='normal', user_id=[qq_id], message_ty...
          │       │   └ Bot(type='OneBot V11', self_id='2037909602')
          │       └ <function Matcher.run at 0x7fe422ea4790>
          └ Matcher(type='message', module=plugins.nonebot_plugin_chatgpt)
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/nonebot/internal/matcher.py", line 716, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
          │    │          │    │      │      │      └ {<function _command at 0x7fe422ea4c10>: <Task finished name='Task-148474' coro=<_command() done, defined at /home/jason/.cach...
          │    │          │    │      │      └ <contextlib.AsyncExitStack object at 0x7fe3fc4cdc30>
          │    │          │    │      └ {'_prefix': {'command': None, 'raw_command': None, 'command_arg': None, 'command_start': None}}
          │    │          │    └ GroupMessageEvent(time=1670249093, self_id=2037909602, post_type='message', sub_type='normal', user_id=[qq_id], message_ty...
          │    │          └ Bot(type='OneBot V11', self_id='2037909602')
          │    └ <function Matcher.simple_run at 0x7fe422ea4700>
          └ Matcher(type='message', module=plugins.nonebot_plugin_chatgpt)
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/nonebot/internal/matcher.py", line 688, in simple_run
    await handler(
          └ Dependent(call=_)
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/nonebot/dependencies/__init__.py", line 108, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
                 │    │             │         │    │    │       └ {'event': GroupMessageEvent(time=1670249093, self_id=2037909602, post_type='message', sub_type='normal', user_id=[qq_id], ...
                 │    │             │         │    │    └ <function _ at 0x7fe40350f400>
                 │    │             │         │    └ Dependent(call=_)
                 │    │             │         └ ~R
                 │    │             └ typing.Awaitable
                 │    └ typing.Callable
                 └ <function cast at 0x7fe4247945e0>

  File "/home/jason/zhenxun_bot/plugins/nonebot_plugin_chatgpt/__init__.py", line 44, in _
    msg = await chat_bot(**session[event.user_id]).get_chat_response(text)
                │          │       │     │                           └ '如何评价原神抄袭塞尔达'
                │          │       │     └ [qq_id]
                │          │       └ GroupMessageEvent(time=1670249093, self_id=2037909602, post_type='message', sub_type='normal', user_id=[qq_id], message_ty...
                │          └ defaultdict(<class 'dict'>, {[qq_id]: {'conversation_id': 'ae0dadb7-56b9-4d44-8be9-484e5dc1d123', 'parent_id': 'da634643-a...
                └ <plugins.nonebot_plugin_chatgpt.chatgpt.Chatbot object at 0x7fe403575a80>

  File "/home/jason/zhenxun_bot/plugins/nonebot_plugin_chatgpt/chatgpt.py", line 65, in get_chat_response
    response = await client.post(
                     │      └ <function AsyncClient.post at 0x7fe421849510>
                     └ <httpx.AsyncClient object at 0x7fe401dbe590>

  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 1842, in post
    return await self.request(
                 │    └ <function AsyncClient.request at 0x7fe421848f70>
                 └ <httpx.AsyncClient object at 0x7fe401dbe590>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 1527, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
                 │    │    │             │                      └ <httpx._client.UseClientDefault object at 0x7fe421af2a70>
                 │    │    │             └ <httpx._client.UseClientDefault object at 0x7fe421af2a70>
                 │    │    └ <Request('POST', 'https://chat.openai.com/backend-api/conversation')>
                 │    └ <function AsyncClient.send at 0x7fe421849120>
                 └ <httpx.AsyncClient object at 0x7fe401dbe590>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 1614, in send
    response = await self._send_handling_auth(
                     │    └ <function AsyncClient._send_handling_auth at 0x7fe4218491b0>
                     └ <httpx.AsyncClient object at 0x7fe401dbe590>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 1642, in _send_handling_auth
    response = await self._send_handling_redirects(
                     │    └ <function AsyncClient._send_handling_redirects at 0x7fe421849240>
                     └ <httpx.AsyncClient object at 0x7fe401dbe590>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 1679, in _send_handling_redirects
    response = await self._send_single_request(request)
                     │    │                    └ <Request('POST', 'https://chat.openai.com/backend-api/conversation')>
                     │    └ <function AsyncClient._send_single_request at 0x7fe4218492d0>
                     └ <httpx.AsyncClient object at 0x7fe401dbe590>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 1716, in _send_single_request
    response = await transport.handle_async_request(request)
                     │         │                    └ <Request('POST', 'https://chat.openai.com/backend-api/conversation')>
                     │         └ <function AsyncHTTPTransport.handle_async_request at 0x7fe421a2a830>
                     └ <httpx.AsyncHTTPTransport object at 0x7fe3fd8c6b60>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py", line 352, in handle_async_request
    with map_httpcore_exceptions():
         └ <function map_httpcore_exceptions at 0x7fe4219e3370>
  File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
    │    │   │     │    │      └ <traceback object at 0x7fe401ebf780>
    │    │   │     │    └ ReadTimeout(TimeoutError())
    │    │   │     └ <class 'httpcore.ReadTimeout'>
    │    │   └ <method 'throw' of 'generator' objects>
    │    └ <generator object map_httpcore_exceptions at 0x7fe4221a3f40>
    └ <contextlib._GeneratorContextManager object at 0x7fe3fd8c7d60>
  File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
          │          └ ''
          └ <class 'httpx.ReadTimeout'>

httpx.ReadTimeout

额外补充

抱歉没有控制台截图

[Feature]: 优化图片发送功能

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

希望能优化图片发送功能

对于普通对话而言,一直发送图片似乎显得太机械了,能否识别html文本中的渲染部分,独立地将需要特殊渲染的部分做成图片嵌入到消息中分开发送?

您想要的解决方案

希望能通过正则化等方法将html解析出来,然后稍微美化一下图片,最好像网页中的截图那样。

您考虑过的替代方案

No response

实现的功能是什么样的?

效果大概像这样:
)P@M3CJWT(IB)HB8KQ TQV

还有什么要补充的吗?

顺带一提,默认设置下好像重置会话等操作不起作用,可以优化一下吗

[BUG]: 在.env.dev 中开启CHATGPT_IMAGE=true 出现报错

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

0.7.0

问题描述

在.env.dev 中开启CHATGPT_IMAGE=true 出现报错

复现步骤

在.env.dev 中开启CHATGPT_IMAGE=true 出现报错

预期行为

返回图片

实际行为

playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded.

日志信息

File "/home/zx-bot/zhenxun_bot/bot.py", line 22, in
nonebot.run()
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/nonebot/init.py", line 273, in run
get_driver().run(*args, **kwargs)
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/nonebot/drivers/fastapi.py", line 172, in run
uvicorn.run(
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/uvicorn/main.py", line 576, in run
server.run()
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
File "/usr/local/python3/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/nonebot/message.py", line 142, in _check_matcher
await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)

File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/nonebot/message.py", line 186, in _run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 716, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 688, in simple_run
await handler(
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/nonebot/dependencies/init.py", line 108, in call
return await cast(Callable[..., Awaitable[R]], self.call)(**values)
File "/home/zx-bot/zhenxun_bot/my_plugins/nonebot_plugin_chatgpt/init.py", line 77, in ai_chat
img = await md_to_pic(msg, width=config.chatgpt_image_width)
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/nonebot_plugin_htmlrender/date_source.py", line 96, in md_to_pic
return await html_to_pic(
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/nonebot_plugin_htmlrender/date_source.py", line 162, in html_to_pic
img_raw = await page.screenshot(full_page=True)
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/playwright/async_api/_generated.py", line 8691, in screenshot
await self._impl_obj.screenshot(
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/playwright/_impl/_page.py", line 654, in screenshot
encoded_binary = await self._channel.send("screenshot", params)
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 43, in send
return await self._connection.wrap_api_call(
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 396, in wrap_api_call
return await cb()
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-dd6N0HXn-py3.9/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 78, in inner_send
result = next(iter(done)).result()
playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded.
=========================== logs ===========================
taking page screenshot
============================================================

额外补充

No response

[Feature]: 是否有计划增加简单的指令使得bot可以转换为txt文件并发送,以及对图片的识别?

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

增加简单的指令使得bot可以转换为txt文件并发送
对图片的识别

您想要的解决方案

通过对话可以添加单次指令 使得bot可以转换为txt文件并发送,并可以在设置中设置bot默认使用txt文件回复或者其它形式回复
对图片的识别

您考虑过的替代方案

No response

实现的功能是什么样的?

No response

还有什么要补充的吗?

No response

[BUG]: 请求 ChatGPT 服务器时出现问题

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

0.7.2

问题描述

ubuntu22.04,香港腾讯云

向bot发起对话,提示:请求 ChatGPT 服务器时出现问题,请稍后再试
错误信息: AttributeError: 'NoneType' object has no attribute 'new_page'
Snipaste_2022-12-16_15-01-37

主要报了以下两条错误:

第一条提示未安装playwright,但是我确实已经安装了

Snipaste_2022-12-16_14-49-33

另外一条如下,与bot返回的信息相同

Snipaste_2022-12-16_14-50-08
Snipaste_2022-12-16_14-50-36

复现步骤

1.启动bot
2.向bot发送消息

预期行为

正常回复

实际行为

请求服务器出现问题

日志信息

12-16 14:44:58 [ERROR] nonebot_plugin_chatgpt | playwright未安装,请先在shell中运行playwright install
Traceback (most recent call last):
File "/usr/local/bin/nb", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1130, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/nb_cli/commands/main.py", line 30, in run
run_bot(file, app)
File "/usr/local/lib/python3.10/dist-packages/nb_cli/handlers/deploy.py", line 25, in run_bot
nonebot.run(app=f"{module_name}:{app}")
File "/usr/local/lib/python3.10/dist-packages/nonebot/init.py", line 273, in run
get_driver().run(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/nonebot/drivers/fastapi.py", line 172, in run
uvicorn.run(
File "/usr/local/lib/python3.10/dist-packages/uvicorn/main.py", line 569, in run
server.run()
File "/usr/local/lib/python3.10/dist-packages/uvicorn/server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.10/dist-packages/nonebot/message.py", line 142, in _check_matcher
await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
File "/usr/local/lib/python3.10/dist-packages/nonebot/message.py", line 188, in _run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "/usr/local/lib/python3.10/dist-packages/nonebot/internal/matcher/matcher.py", line 727, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "/usr/local/lib/python3.10/dist-packages/nonebot/internal/matcher/matcher.py", line 702, in simple_run
await handler(
File "/usr/local/lib/python3.10/dist-packages/nonebot/dependencies/init.py", line 108, in call
return await cast(Callable[..., Awaitable[R]], self.call)(**values)
File "/usr/local/lib/python3.10/dist-packages/nonebot_plugin_chatgpt/init.py", line 57, in ai_chat
await chat_bot.playwright_start()

File "/usr/local/lib/python3.10/dist-packages/nonebot_plugin_chatgpt/chatgpt.py", line 55, in playwright_start
self.browser = await playwright.firefox.launch(
File "/usr/local/lib/python3.10/dist-packages/playwright/async_api/_generated.py", line 12809, in launch
await self._impl_obj.launch(
File "/usr/local/lib/python3.10/dist-packages/playwright/_impl/_browser_type.py", line 93, in launch
Browser, from_channel(await self._channel.send("launch", params))
File "/usr/local/lib/python3.10/dist-packages/playwright/_impl/_connection.py", line 44, in send
return await self._connection.wrap_api_call(
File "/usr/local/lib/python3.10/dist-packages/playwright/_impl/_connection.py", line 419, in wrap_api_call
return await cb()
File "/usr/local/lib/python3.10/dist-packages/playwright/_impl/_connection.py", line 79, in inner_send
result = next(iter(done)).result()
playwright._impl._api_types.Error: Browser.enable): Browser closed.
==================== Browser output: ====================
/root/.cache/ms-playwright/firefox-1364/firefox/firefox -no-remote -headless -profile /tmp/playwright_firefoxdev_profile-V2g2IG -juggler-pipe -silent
pid=1102855
[pid=1102855][err] Running Nightly as root in a regular user's session is not supported. ($XDG_RUNTIME_DIR is /run/user/1000 which is owned by ubuntu.)
[pid=1102855]
[pid=1102855] starting temporary directories cleanup
=========================== logs ===========================
/root/.cache/ms-playwright/firefox-1364/firefox/firefox -no-remote -headless -profile /tmp/playwright_firefoxdev_profile-V2g2IG -juggler-pipe -silent
pid=1102855
[pid=1102855][err] Running Nightly as root in a regular user's session is not supported. ($XDG_RUNTIME_DIR is /run/user/1000 which is owned by ubuntu.)
[pid=1102855]
[pid=1102855] starting temporary directories cleanup
============================================================
12-16 14:44:58 [ERROR] nonebot_plugin_chatgpt | ChatGPT request failed: AttributeError: 'NoneType' object has no attribute 'new_page'
Traceback (most recent call last):
File "/usr/local/bin/nb", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1130, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/nb_cli/commands/main.py", line 30, in run
run_bot(file, app)
File "/usr/local/lib/python3.10/dist-packages/nb_cli/handlers/deploy.py", line 25, in run_bot
nonebot.run(app=f"{module_name}:{app}")
File "/usr/local/lib/python3.10/dist-packages/nonebot/init.py", line 273, in run
get_driver().run(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/nonebot/drivers/fastapi.py", line 172, in run
uvicorn.run(
File "/usr/local/lib/python3.10/dist-packages/uvicorn/main.py", line 569, in run
server.run()
File "/usr/local/lib/python3.10/dist-packages/uvicorn/server.py", line 60, in run
uvicorn.run(
File "/usr/local/lib/python3.10/dist-packages/uvicorn/main.py", line 569, in run
server.run()
File "/usr/local/lib/python3.10/dist-packages/uvicorn/server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.10/dist-packages/nonebot/message.py", line 142, in _check_matcher
await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
File "/usr/local/lib/python3.10/dist-packages/nonebot/message.py", line 188, in _run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "/usr/local/lib/python3.10/dist-packages/nonebot/internal/matcher/matcher.py", line 727, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "/usr/local/lib/python3.10/dist-packages/nonebot/internal/matcher/matcher.py", line 702, in simple_run
await handler(
File "/usr/local/lib/python3.10/dist-packages/nonebot/dependencies/init.py", line 108, in call
return await cast(Callable[..., Awaitable[R]], self.call)(**values)
File "/usr/local/lib/python3.10/dist-packages/nonebot_plugin_chatgpt/init.py", line 63, in ai_chat
msg = await chat_bot(**session[event]).get_chat_response(text)
File "/usr/local/lib/python3.10/dist-packages/nonebot_plugin_chatgpt/chatgpt.py", line 123, in get_chat_response
async with self.get_page() as page:
File "/usr/lib/python3.10/contextlib.py", line 199, in aenter
return await anext(self.gen)
File "/usr/local/lib/python3.10/dist-packages/nonebot_plugin_chatgpt/chatgpt.py", line 115, in get_page
page = await self.content.new_page()
AttributeError: 'NoneType' object has no attribute 'new_page'

额外补充

No response

[Question]: 我调高了优先级,但是不能向下阻断

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

我将 params: Dict[str, Any] = {"priority": 999} 改为了 50 ,可是这样不能向下阻断,
我尝试加入 block = True ,可是我不知道加在哪里TAT。

您想要的解决方案

增加一个阻断。

您考虑过的替代方案

No response

实现的功能是什么样的?

No response

还有什么要补充的吗?

No response

[BUG]: httpx.RemoteProtocolError: peer closed connection without sending complete message body (incomplete chunked read)

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

尚未合并的pr

问题描述

在遇到openai返回大量长文本时,由于openai目前日常不稳定,很可能写到一半突然暴毙。并且,该bug在网页版上也成功复现,所以并非代码导致的问题。
这个bug导致我们无法看到写到一半的文本

复现步骤

诱导模型发一长段话,例如写代码

预期行为

如果可以的话,希望可以返回文本流中已经得到的内容,并加上提示,该次对话不会更新id
例如:
ChatGPT 服务器中断了生成,可能由于服务器不稳定,已经获取到的回复:xxx

实际行为

请求 ChatGPT 服务器时出现问题,请稍后再试
错误信息: RemoteProtocolError: peer closed connection without sending complete message body (incomplete chunked read)

日志信息

No response

额外补充

No response

[BUG]: 无痕浏览器一直打开再关闭

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

目前最新的版本

问题描述

无痕浏览器不停地访问网站,似乎登录进去了,但是又自己关闭了 ,如此循环

复现步骤

1,更改了新的版本
2,安装了依赖

预期行为

正常运行

实际行为

浏览器无限闪退,谷歌浏览器

日志信息

12-13 20:00:27 [ERROR] nonebot_plugin_chatgpt | 刷新会话失败: <r>HTTP403</r> <!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Just a moment...</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="robots" content="noindex,nofollow">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link href="/cdn-cgi/styles/challenges.css" rel="stylesheet">
    

</head>
<body class="no-js">
    <div class="main-wrapper" role="main">
    <div class="main-content">
        <h1 class="zone-name-title h1">
            <img class="heading-favicon" src="/favicon.ico"
                 onerror="this.onerror=null;this.parentNode.removeChild(this)">
            chat.openai.com
        </h1>
        <h2 class="h2" id="challenge-running">
            Checking if the site connection is secure
        </h2>
        <noscript>
            <div id="challenge-error-title">
                <div class="h2">
                    <span class="icon-wrapper">
                        <div class="heading-icon warning-icon"></div>
                    </span>
                    <span id="challenge-error-text">
                        Enable JavaScript and cookies to continue
                    </span>
                </div>
            </div>
        </noscript>
        <div id="trk_jschal_js" style="display:none;background-image:url('/cdn-cgi/images/trace/managed/nojs/transparent.gif?ray=778e89db1898afe1')"></div>
        <div id="challenge-body-text" class="core-msg spacer">
            chat.openai.com needs to review the security of your connection before proceeding.
        </div>
        <form id="challenge-form" action="/api/auth/session?__cf_chl_f_tk=Xv9VV3oCdKN3UFqhJQJsvtQ1_5bUAXjEE4WESHQsJfI-1670932817-0-gaNycGzNEr0" method="POST" enctype="application/x-www-form-urlencoded">
            <input type="hidden" name="md" value="kU5LapJopg2kJ2lBLM3uZ8mn0kd43fiv5sF67fri35M-1670932817-0-Ad9ihwUNMKK9hSOZm0MCN2_PB1zOIE_Y3XOOWtRCk6Q4w0lY_ZFexhoR3yHcjRnzKBPvcStR6b_4hUZn7G5iRrbzJN3-hijcucYAFUQ1UlYT_ni8RQgt3vt3XYaSYu-ponJJv0GwJ4sFvmACKHPbL_aFjX5nBqcf3fh2fvZCg3Kbo1l_kC0DPUAgkcKtx2ftlD8ra5gcFXkxNEypnbPTQXYzzoLdOTDjGs17e7ZxE7GwbUbwTqIupv8OILts-di69E_m6s5iPVs-kn3AEpXUTbxtur-2xrqU2R3dnk7SLbLNdxiuaL860I6NDwXjl0yytyy_vjr_KKGNGieKKADN59JMcPWGLObbwUP3WafPL_31DUnnitG-dqo3hRojnoTUyESlA4406eSMypIk7b-1lI6AwwZLHDUnFEIeTIFknS16UYVVffYhkXkSoc1v1WbG-16u9TeN9YCdVCYS1LB9sUi9OhHZXjE4BFvBcD5osBuLOKMnESGHVMl_MGT4JajAIY3lfRskMIg-cBLTrvLDh6_EnLWK_hTCa3wA1IkM0r8Usn3AHyC0vX04EY6kioan-Xu7Km_OfavVOeAAdAgRKhxbzBpTh0YtosSbTrPmcWrq-Nk3Iaop8lV9PZh8OTyW0Owdqx-ekAd3QzPVZZzAesibjO3bmORJ3X0rndBDL-apE3QYKshgHmoR4eojBKUcVA">
            <input type="hidden" name="r" value="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">
        </form>
    </div>
</div>
<script>
    (function(){
        window._cf_chl_opt={
            cvId: '2',
            cType: 'managed',
            cNounce: '95508',
            cRay: '778e89db1898afe1',
            cHash: '64ea0bd54c22486',
            cUPMDTk: "\/api\/auth\/session?__cf_chl_tk=Xv9VV3oCdKN3UFqhJQJsvtQ1_5bUAXjEE4WESHQsJfI-1670932817-0-gaNycGzNEr0",
            cFPWv: 'b',
            cTTimeMs: '1000',
            cTplV: 4,
            cTplB: 'cf',
            cRq: {
                ru: 'aHR0cHM6Ly9jaGF0Lm9wZW5haS5jb20vY2hhdC9mcm9udGVuZC8vYXBpL2F1dGgvc2Vzc2lvbg==',
                ra: 'TW96aWxsYS81LjAgKFgxMTsgTGludXggeDg2XzY0KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWl1bS8xMDcuMC41MzA0LjE4IFNhZmFyaS81MzcuMzY=',
                rm: 'R0VU',
                d: 'eMkxHxR8H6c3ngDJLuo5HS1PkXxz9UczrRYpibkVim80i4dvwcvOZrYkxA6Et5Tztd5Wsao0iStrZ7XypHxFKRWHgbnOeUyNL6s41BU6WyLw0nlGtQl7My/sy5b84MCtw1mv0+bNK7qq9axDlPJmQzVGgk9tSc3t+XXXdj7gmrwR5NRUOgNpjsymHlxyRkMGJv82wYVjnZpWpTdMxeyhIfGART51+Y2H8vcpIO5GiX8/+LywB1MyVZA3wcvaZ5GWbz2h3KrDfX5P9AOnD7nIEcKaitY+VHW/KsxTUq7QXwcZPo5Amk7mHKaav1o/lNYvpHbdX6AcCayrPkyxH/f3Y5dxH8J809lmTIZbKQhjTdRSNzfNsuAejr9akPbFlgRPfc2S2Aub8rbvB1auE/N3NASugPGPc8TdOO/1YRJti6ZJZklMQYSTTaKpUvDyX7vMdKRzYpgGMLmOkK9QfP23+qjyORgQsw2NrXobTsnVJPVGhMY3/jfjR5/gNcGHN6QPbG+ZHoIRZdjk4B9B/2L2Yek5NJy3c0rGhvVT6M8bObLvBB+u56KAIPlOHhhoyoeOLyc7jiLicqCDVHKoxhxnzU7gO30EicxmsKlZZ9sGcSrwVkdyED8jmS3B4S6QomGZHGflul83BEW6N2rwsw6rLQ==',
                t: 'MTY3MDkzMjgxNy4xNDMwMDA=',
                m: '0eycBGGxbOOz6drd7LBb24TsP8a+ukmKTLWSuCS6Zno=',
                i1: 'PE6kKKniLZrm4GjS3LQKkA==',
                i2: 'D0TGMd73Ep7ZwvGWV60Fzg==',
                zh: 'iuyN59AGNgeBFFEOPj72EN+xtBfXXvoCyd1dJnIVFAc=',
                uh: 'voffhCpB/+YvUOGFnoTcV4dT1DvSdH3/F/Qf+7kfxOY=',
                hh: 'foaWmAUHGGlVCZaNUJIHhxzxFNzSPNnVe6rJjiQw728=',
            }
        };
        var trkjs = document.createElement('img');
        trkjs.setAttribute('src', '/cdn-cgi/images/trace/managed/js/transparent.gif?ray=778e89db1898afe1');
        trkjs.setAttribute('style', 'display: none');
        document.body.appendChild(trkjs);
        var cpo = document.createElement('script');
        cpo.src = '/cdn-cgi/challenge-platform/h/b/orchestrate/managed/v1?ray=778e89db1898afe1';
        window._cf_chl_opt.cOgUHash = location.hash === '' && location.href.indexOf('#') !== -1 ? '#' : location.hash;
        window._cf_chl_opt.cOgUQuery = location.search === '' && location.href.slice(0, -window._cf_chl_opt.cOgUHash.length).indexOf('?') !== -1 ? '?' : location.search;
        if (window.history && window.history.replaceState) {
            var ogU = location.pathname + window._cf_chl_opt.cOgUQuery + window._cf_chl_opt.cOgUHash;
            history.replaceState(null, null, "\/api\/auth\/session?__cf_chl_rt_tk=Xv9VV3oCdKN3UFqhJQJsvtQ1_5bUAXjEE4WESHQsJfI-1670932817-0-gaNycGzNEr0" + window._cf_chl_opt.cOgUHash);
            cpo.onload = function() {
                history.replaceState(null, null, ogU);
            };
        }
        document.getElementsByTagName('head')[0].appendChild(cpo);
    }());
</script>


    <div class="footer" role="contentinfo">
        <div class="footer-inner">
            <div class="clearfix diagnostic-wrapper">
                <div class="ray-id">Ray ID: <code>778e89db1898afe1</code></div>
            </div>
            <div class="text-center">Performance &amp; security by <a rel="noopener noreferrer" href="https://www.cloudflare.com?utm_source=challenge&utm_campaign=m" target="_blank">Cloudflare</a></div>
        </div>
    </div>
</body>
</html>

Traceback (most recent call last):
  File "D:\NoneBot2\homura\src\plugins\nonebot_plugin_chatgpt\chatgpt.py", line 199, in get_cf_cookies
    cf_clearance = next(filter(lambda x: x["name"] == "cf_clearance", cookies))
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\NoneBot2\homura\bot.py", line 37, in <module>
    nonebot.run(app="__mp_main__:app")
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nonebot\__init__.py", line 273, in run
    get_driver().run(*args, **kwargs)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nonebot\drivers\fastapi.py", line 172, in run
    uvicorn.run(
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\uvicorn\main.py", line 576, in run
    server.run()
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\uvicorn\server.py", line 60, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "D:\conda_data\envs\Python3.8.15\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "D:\conda_data\envs\Python3.8.15\lib\asyncio\base_events.py", line 603, in run_until_complete
    self.run_forever()
  File "D:\conda_data\envs\Python3.8.15\lib\asyncio\windows_events.py", line 316, in run_forever
    super().run_forever()
  File "D:\conda_data\envs\Python3.8.15\lib\asyncio\base_events.py", line 570, in run_forever
    self._run_once()
  File "D:\conda_data\envs\Python3.8.15\lib\asyncio\base_events.py", line 1859, in _run_once
    handle._run()
  File "D:\conda_data\envs\Python3.8.15\lib\asyncio\events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nonebot\message.py", line 142, in _check_matcher
    await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nonebot\message.py", line 186, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nonebot\internal\matcher.py", line 716, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nonebot\internal\matcher.py", line 688, in simple_run
    await handler(
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nonebot\dependencies\__init__.py", line 108, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
  File "D:\NoneBot2\homura\src\plugins\nonebot_plugin_chatgpt\__init__.py", line 60, in ai_chat
    msg = await chat_bot(**session[event]).get_chat_response(text)
  File "D:\NoneBot2\homura\src\plugins\nonebot_plugin_chatgpt\chatgpt.py", line 91, in get_chat_response
    await self.refresh_session()
  File "D:\NoneBot2\homura\src\plugins\nonebot_plugin_chatgpt\chatgpt.py", line 140, in refresh_session
    await self.refresh_session()
  File "D:\NoneBot2\homura\src\plugins\nonebot_plugin_chatgpt\chatgpt.py", line 140, in refresh_session
    await self.refresh_session()
  File "D:\NoneBot2\homura\src\plugins\nonebot_plugin_chatgpt\chatgpt.py", line 140, in refresh_session
    await self.refresh_session()
  [Previous line repeated 2 more times]
> File "D:\NoneBot2\homura\src\plugins\nonebot_plugin_chatgpt\chatgpt.py", line 139, in refresh_session
    await self.get_cf_cookies()
RuntimeError: coroutine raised StopIteration
12-13 20:00:28 [ERROR] nonebot_plugin_chatgpt | ChatGPT request failed: LocalProtocolError: Illegal header value b'Bearer '
Traceback (most recent call last):
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpcore\_exceptions.py", line 10, in map_exceptions
    yield
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpcore\_async\http11.py", line 121, in _send_request_headers
    event = h11.Request(
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\h11\_events.py", line 96, in __init__
    self, "headers", normalize_and_validate(headers, _parsed=_parsed)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\h11\_headers.py", line 164, in normalize_and_validate
    validate(_field_value_re, value, "Illegal header value {!r}", value)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\h11\_util.py", line 91, in validate
    raise LocalProtocolError(msg)
h11._util.LocalProtocolError: Illegal header value b'Bearer '

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpx\_transports\default.py", line 60, in map_httpcore_exceptions
    yield
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpx\_transports\default.py", line 353, in handle_async_request
    resp = await self._pool.handle_async_request(req)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpcore\_async\connection_pool.py", line 253, in handle_async_request
    raise exc
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpcore\_async\connection_pool.py", line 237, in handle_async_request
    response = await connection.handle_async_request(request)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpcore\_async\connection.py", line 90, in handle_async_request
    return await self._connection.handle_async_request(request)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpcore\_async\http11.py", line 112, in handle_async_request
    raise exc
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpcore\_async\http11.py", line 80, in handle_async_request
    await self._send_request_headers(**kwargs)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpcore\_async\http11.py", line 121, in _send_request_headers
    event = h11.Request(
  File "D:\conda_data\envs\Python3.8.15\lib\contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpcore\_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc)
httpcore.LocalProtocolError: Illegal header value b'Bearer '

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\NoneBot2\homura\bot.py", line 37, in <module>
    nonebot.run(app="__mp_main__:app")
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nonebot\__init__.py", line 273, in run
    get_driver().run(*args, **kwargs)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nonebot\drivers\fastapi.py", line 172, in run
    uvicorn.run(
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\uvicorn\main.py", line 576, in run
    server.run()
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\uvicorn\server.py", line 60, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "D:\conda_data\envs\Python3.8.15\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "D:\conda_data\envs\Python3.8.15\lib\asyncio\base_events.py", line 603, in run_until_complete
    self.run_forever()
  File "D:\conda_data\envs\Python3.8.15\lib\asyncio\windows_events.py", line 316, in run_forever
    super().run_forever()
  File "D:\conda_data\envs\Python3.8.15\lib\asyncio\base_events.py", line 570, in run_forever
    self._run_once()
  File "D:\conda_data\envs\Python3.8.15\lib\asyncio\base_events.py", line 1859, in _run_once
    handle._run()
  File "D:\conda_data\envs\Python3.8.15\lib\asyncio\events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nonebot\message.py", line 142, in _check_matcher
    await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nonebot\message.py", line 186, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nonebot\internal\matcher.py", line 716, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nonebot\internal\matcher.py", line 688, in simple_run
    await handler(
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nonebot\dependencies\__init__.py", line 108, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
> File "D:\NoneBot2\homura\src\plugins\nonebot_plugin_chatgpt\__init__.py", line 60, in ai_chat
    msg = await chat_bot(**session[event]).get_chat_response(text)
  File "D:\NoneBot2\homura\src\plugins\nonebot_plugin_chatgpt\chatgpt.py", line 96, in get_chat_response
    response = await client.post(
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpx\_client.py", line 1848, in post
    return await self.request(
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpx\_client.py", line 1533, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpx\_client.py", line 1620, in send
    response = await self._send_handling_auth(
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpx\_client.py", line 1648, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpx\_client.py", line 1685, in _send_handling_redirects
    response = await self._send_single_request(request)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpx\_client.py", line 1722, in _send_single_request
    response = await transport.handle_async_request(request)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpx\_transports\default.py", line 353, in handle_async_request
    resp = await self._pool.handle_async_request(req)
  File "D:\conda_data\envs\Python3.8.15\lib\contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\httpx\_transports\default.py", line 77, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.LocalProtocolError: Illegal header value b'Bearer '

额外补充

请帮我检查是否是文件更改错误谢谢:
以下是chatgpt.py:

import uuid
from typing import Any, Dict, Optional
from urllib.parse import urljoin
import asyncio
import httpx
from nonebot.log import logger
from nonebot.utils import escape_tag, run_sync
from typing_extensions import Self

try:
    import ujson as json
except ModuleNotFoundError:
    import json
from playwright.async_api import async_playwright

js = "Object.defineProperties(navigator, {webdriver:{get:()=>undefined}});"

SESSION_TOKEN_KEY = "__Secure-next-auth.session-token"
CF_CLEARANCE_KEY = "cf_clearance"

class Chatbot:
    def __init__(
        self,
        *,
        token: str = "",
        account: str = "",
        password: str = "",
        api: str = "https://chat.openai.com/",
        proxies: Optional[str] = None,
        timeout: int = 10,
    ) -> None:
        self.session_token = token
        self.account = account
        self.password = password
        self.api_url = api
        self.proxies = proxies
        self.timeout = timeout
        self.authorization = ""
        self.cf_clearance = ""
        self.user_agent = ""

        if self.session_token:
            self.auto_auth = False
        elif self.account and self.password:
            self.auto_auth = True
        else:
            raise ValueError("至少需要配置 session_token 或者 account 和 password")

    def __call__(
        self, conversation_id: Optional[str] = None, parent_id: Optional[str] = None
    ) -> Self:
        self.conversation_id = conversation_id[-1] if conversation_id else None
        self.parent_id = parent_id[-1] if parent_id else self.id
        return self

    @property
    def id(self) -> str:
        return str(uuid.uuid4())

    @property
    def headers(self) -> Dict[str, str]:
        return {
            "Host": "chat.openai.com",
            "Accept": "text/event-stream",
            "Authorization": f"Bearer {self.authorization}",
            "Content-Type": "application/json",
            "User-Agent": self.user_agent,
            "X-Openai-Assistant-App-Id": "",
            "Connection": "close",
            "Accept-Language": "en-US,en;q=0.9",
            "Referer": "https://chat.openai.com/chat",
        }

    def get_payload(self, prompt: str) -> Dict[str, Any]:
        return {
            "action": "next",
            "messages": [
                {
                    "id": self.id,
                    "role": "user",
                    "content": {"content_type": "text", "parts": [prompt]},
                }
            ],
            "conversation_id": self.conversation_id,
            "parent_message_id": self.parent_id,
            "model": "text-davinci-002-render",
        }

    async def get_chat_response(self, prompt: str) -> str:
        if not self.authorization:
            await self.refresh_session()
        cookies = {SESSION_TOKEN_KEY: self.session_token}
        if self.cf_clearance:
            cookies[CF_CLEARANCE_KEY] = self.cf_clearance
        async with httpx.AsyncClient(proxies=self.proxies) as client:
            response = await client.post(
                urljoin(self.api_url, "backend-api/conversation"),
                headers=self.headers,
                cookies=cookies,
                json=self.get_payload(prompt),
                timeout=self.timeout,
            )
        if response.status_code == 429:
            return "请求过多,请放慢速度"
        if response.status_code == 401:
            return "token失效,请重新设置token"
        if response.is_error:
            logger.error(
                f"非预期的响应内容: <r>HTTP{response.status_code}</r> {response.text}"
            )
            return f"ChatGPT 服务器返回了非预期的内容: HTTP{response.status_code}\n{response.text}"
        lines = response.text.splitlines()
        data = lines[-4][6:]
        response = json.loads(data)
        self.parent_id = response["message"]["id"]
        self.conversation_id = response["conversation_id"]
        return response["message"]["content"]["parts"][0]

    async def refresh_session(self) -> None:
        if self.auto_auth:
            await self.login()
        else:
            cookies = {SESSION_TOKEN_KEY: self.session_token}
            if self.cf_clearance:
                cookies[CF_CLEARANCE_KEY] = self.cf_clearance
            async with httpx.AsyncClient(
                cookies=cookies,
                proxies=self.proxies,
                timeout=self.timeout,
            ) as client:
                response = await client.get(
                    urljoin(self.api_url, "api/auth/session"),
                    headers={
                        "User-Agent": self.user_agent,
                    },
                )
            try:
                if response.status_code == 403:
                    await self.get_cf_cookies()
                    await self.refresh_session()
                    return
                self.session_token = (
                    response.cookies.get(SESSION_TOKEN_KEY) or self.session_token
                )
                self.authorization = response.json()["accessToken"]
            except Exception as e:
                logger.opt(exception=e).error(
                    f"刷新会话失败: <r>HTTP{response.status_code}</r> {response.text}"
                )

    @run_sync
    def login(self) -> None:
        from OpenAIAuth.OpenAIAuth import OpenAIAuth

        auth = OpenAIAuth(self.account, self.password, bool(self.proxies), self.proxies)  # type: ignore
        try:
            auth.begin()
        except Exception as e:
            if str(e) == "Captcha detected":
                logger.error("不支持验证码, 请使用 session token")
            raise e
        if not auth.access_token:
            logger.error("ChatGPT 登陆错误!")
        self.authorization = auth.access_token
        if auth.session_token:
            self.session_token = auth.session_token
        elif possible_tokens := auth.session.cookies.get(SESSION_TOKEN_KEY):
            if len(possible_tokens) > 1:
                self.session_token = possible_tokens[0]
            else:
                try:
                    self.session_token = possible_tokens
                except Exception as e:
                    logger.opt(exception=e).error("ChatGPT 登陆错误!")
        else:
            logger.error("ChatGPT 登陆错误!")

    async def get_cf_cookies(self) -> None:
        async with async_playwright() as p:
            browser = await p.chromium.launch(
                headless=False,
                args=[
                    "--disable-extensions",
                    "--disable-application-cache",
                    "--disable-gpu",
                    "--disable-setuid-sandbox",
                    "--disable-dev-shm-usage",
                    "--incognito",
                ],
                proxy={"server": self.proxies} if self.proxies else None,  # your proxy
            )
            ua = f"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chromium/{browser.version} Safari/537.36"
            content = await browser.new_context(user_agent=ua)
            page = await content.new_page()
            await page.add_init_script(js)
            await page.goto("https://chat.openai.com/chat")
            await asyncio.sleep(5)
            cookies = await content.cookies()
            cf_clearance = next(filter(lambda x: x["name"] == "cf_clearance", cookies))
            self.cf_clearance = cf_clearance["value"]
            self.user_agent=ua
            await page.close()
            await content.close()
            await browser.close()

[BUG]: 收到信息之后一直卡在“Checking for matchers in priority 1...” /echo可以正常使用

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

0.7.0

问题描述

卡在Checking for matchers in priority 1...

复现步骤

CHATGPT_PRIORITY默认是999,我改成1过后也一直卡住

预期行为

No response

实际行为

No response

日志信息

No response

额外补充

12-14 21:54:18 [SUCCESS] nonebot | OneBot V11 3483352424 | [message.private.friend]: Message 1690041671 from 398886366 "222"
12-14 21:54:18 [DEBUG] nonebot | Checking for matchers in priority 0...
12-14 21:54:18 [DEBUG] nonebot | Checking for matchers in priority 1...

[BUG]: 无法找到__Secure-next-auth.session-token

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

v0.4.0

问题描述

根据教程,在 https://chat.openai.com/chat网址按下F12,切换到 Application/应用 选项卡,找到 Cookies,但是无法找到__Secure-next-auth.session-token。

复现步骤

1.按 F12 打开控制台
切换到 Application/应用 选项卡,找到 Cookies
2.然后并没有找到__Secure-next-auth.session-token这个Name

预期行为

No response

实际行为

No response

日志信息

No response

额外补充

No response

[Feature]: 功能参考

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

https://github.com/Cosmos01/aichat-chatGPT

您想要的解决方案

https://github.com/Cosmos01/aichat-chatGPT

您考虑过的替代方案

No response

实现的功能是什么样的?

No response

还有什么要补充的吗?

No response

[Feature]: 大佬能不能改一下命令方式,改成"提问"或"对话"啥可修改的

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

我的nonebot在调用chatgpt的时候会和另一个聊天ai插件冲突,所以我不得不只选择其中一个进行启动,但我想要两个同时启动,以另一个ai为主,chatgpt为辅。

您想要的解决方案

修改命令方式,不是@机器人启动,而是通过"对话",“提问”等字符串启动,这样就可以两个一起用啦。希望大佬能康康我的问题。

您考虑过的替代方案

No response

实现的功能是什么样的?

No response

还有什么要补充的吗?

No response

[Feature]: 增加 CDtime 来防止请求过频繁造成的 ReadTimeout:

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

ReadTimeout 退退退!!

您想要的解决方案

增加 CDtime

您考虑过的替代方案

No response

实现的功能是什么样的?

No response

还有什么要补充的吗?

No response

[QUESTION]: Tag "<head>" does not correspond to any known ansi directive,

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

Latest

问题描述

无法使用nonebot-plugin-chatgpt插件进行QQ机器人对话
我尝试了重新安装该插件,但是没有解决此问题

复现步骤

1.pip install nonebot-plugin-chatgpt -i https://pypi.tuna.tsinghua.edu.cn/simple
2.在.env中添加了CHATGPT_SESSION_TOKEN
3.在qq中@机器人发送任意消息,回复了以下信息
请求 ChatGPT 服务器时出现问题,请稍后再试
错误信息: ValueError: Tag "" does not correspond to any known ansi directive, make sure you did not misspelled it (or prepend '' to escape it)

预期行为

如OpenAI的ChatGPT那样回复

实际行为

报出错误:
QQ:请求 ChatGPT 服务器时出现问题,请稍后再试
错误信息: ValueError: Tag "" does not correspond to any known ansi directive, make sure you did not misspelled it (or prepend '' to escape it)

后台:

nonebot_plugin_chatgpt | ChatGPT request failed: ValueError: Tag "<head>" does not correspond to any known ansi directive, make sure you did not misspelled it (or prepend '\' to escape it)
Traceback (most recent call last):
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
ValueError: Tag "<head>" does not correspond to any known ansi directive, make sure you did not misspelled it (or prepend '\' to escape it)

日志信息

`[ERROR] nonebot_plugin_chatgpt | ChatGPT request failed: ValueError: Tag "" does not correspond to any known ansi directive, make sure you did not misspelled it (or prepend '' to escape it)
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\site-packages\nonebot_plugin_chatgpt\chatgpt.py", line 128, in refresh_session
self.authorization = response.json()['accessToken']
File "C:\Program Files\Python310\lib\site-packages\httpx_models.py", line 743, in json
return jsonlib.loads(self.text, **kwargs)
File "C:\Program Files\Python310\lib\json_init_.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Program Files\Python310\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Program Files\Python310\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\EnderDragon\EnderDragon3rd\bot.py", line 13, in
nonebot.run(app="mp_main:app")
File "C:\Program Files\Python310\lib\site-packages\nonebot_init_.py", line 273, in run
get_driver().run(*args, **kwargs)
File "C:\Program Files\Python310\lib\site-packages\nonebot\drivers\fastapi.py", line 172, in run
uvicorn.run(
File "C:\Program Files\Python310\lib\site-packages\uvicorn\main.py", line 569, in run
server.run()
File "C:\Program Files\Python310\lib\site-packages\uvicorn\server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
File "C:\Program Files\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Program Files\Python310\lib\asyncio\base_events.py", line 633, in run_until_complete
self.run_forever()
File "C:\Program Files\Python310\lib\asyncio\windows_events.py", line 321, in run_forever
super().run_forever()
File "C:\Program Files\Python310\lib\asyncio\base_events.py", line 600, in run_forever
self._run_once()
File "C:\Program Files\Python310\lib\asyncio\base_events.py", line 1896, in _run_once
handle._run()
File "C:\Program Files\Python310\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "C:\Program Files\Python310\lib\site-packages\nonebot\message.py", line 142, in _check_matcher
await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
File "C:\Program Files\Python310\lib\site-packages\nonebot\message.py", line 188, in run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "C:\Program Files\Python310\lib\site-packages\nonebot\internal\matcher\matcher.py", line 727, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "C:\Program Files\Python310\lib\site-packages\nonebot\internal\matcher\matcher.py", line 702, in simple_run
await handler(
File "C:\Program Files\Python310\lib\site-packages\nonebot\dependencies_init
.py", line 108, in call
return await cast(Callable[..., Awaitable[R]], self.call)(**values)

File "C:\Program Files\Python310\lib\site-packages\nonebot_plugin_chatgpt_init_.py", line 59, in ai_chat
msg = await chat_bot(**session[event]).get_chat_response(text)
File "C:\Program Files\Python310\lib\site-packages\nonebot_plugin_chatgpt\chatgpt.py", line 86, in get_chat_response
await self.refresh_session()
File "C:\Program Files\Python310\lib\site-packages\nonebot_plugin_chatgpt\chatgpt.py", line 130, in refresh_session
logger.opt(colors=True, exception=e).error(
File "C:\Program Files\Python310\lib\site-packages\loguru_colorizer.py", line 369, in prepare_simple_message
parser.feed(string)
File "C:\Program Files\Python310\lib\site-packages\loguru_colorizer.py", line 253, in feed
raise ValueError(
ValueError: Tag "" does not correspond to any known ansi directive, make sure you did not misspelled it (or prepend '' to escape it)`

额外补充

No response

[Feature]: 对于群聊对话context的建议

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

目前在群聊中每一个用户拥有独立的对话,但在群聊中本就是所以用户都能看见的对话,所以希望能够在群聊中以群为范围保存对话context。

您想要的解决方案

每一个群中的对话都是连续的,同一个群的不同用户在群聊中默认加入同一个conversation

您考虑过的替代方案

No response

实现的功能是什么样的?

No response

还有什么要补充的吗?

No response

[BUG]: 私聊或at没反应

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

目前最新的版本

问题描述

机器人无响应

复现步骤

我已在https://chat.openai.com/chat 登录了账号并设置
token=xxxx
之前尝试token=“xxxx”
添加了CHATGPT_COMMAND=""
但是私聊机器人它没反应 我有全局代理

预期行为

回复消息

实际行为

无响应,但是我自己写的插件可以正常响应

日志信息

我不知道日志在哪里,但是主窗口没有错误内容

额外补充

No response

[BUG]: 经常出现httpx.ReadError错误

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

90bffb0

问题描述

在调用插件的过程中,会随机性触发httpx.ReadError错误,详细截图已经放到下文
目前已经发现其他人也遇到了该问题。目前猜测是timeout时间不足导致的,但是由于我对httpx不够了解,不确定具体原因

复现步骤

随机性触发,概率大概在10%左右?
配置中仅设置timeout=30

预期行为

正常情况下他应该正常(

实际行为

事实上他在请求过程中报错了

日志信息

image
image

额外补充

目前chatGPT服务器爆满,默认的10stimeout已经不够使用,是否需要提高默认值?

[BUG]: HTTP401

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

0.5.2

问题描述

TOKEN已经配置,账号密码也配置了,也挂代理了,但是总是出401

复现步骤

chat 测试

预期行为

正常回复

实际行为

返回图片image

日志信息

12-11 00:55:47 [INFO] nonebot | Event will be handled by Matcher(type='message', module=src.plugins.nonebot_plugin_chatgpt)
12-11 00:55:51 [ERROR] nonebot_plugin_chatgpt | 非预期的响应内容: HTTP401 {"detail":{"message":"Your authentication token has expired. Please try signing in again.","type":"invalid_request_error","param":null,"code":"token_expired"}}

额外补充

python3.9.15,ubuntu20.04

[Feature]: 加入可选的全局队列,防止用户较多导致请求次数爆炸

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

用户较多的情况下,个人CD并不能保证单位时间内请求数量在安全范围内

您想要的解决方案

使用一个FIFO缓冲队列,控制同时进行的请求数量

您考虑过的替代方案

No response

实现的功能是什么样的?

用户未开启全局队列的情况下,插件将按照未加入该功能的样子正常工作
在开启全局队列的情况下,用户可以指定同时并发的请求数,当用户的请求进入队列时,BOT会先返回一个等待消息,例如"忙不过来啦,还有{num}人请稍等一下吧"

还有什么要补充的吗?

需要加入一个新文件,fifo.py
需要对原本的处理逻辑进行调整,在命令处理和请求发送之间加入fifo的逻辑
如果该feature被认为需要实现,则在我的插件完成全局队列算法重构后,将算法移植过来

该issue可以用于收集意见,是否支持该功能的实现,如果该feature被认为不需要实现,则废弃

[BUG]: 一直卡在一个页面 然后说遇到人工检验

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

最新版本

问题描述

一直卡在一个页面 然后说遇到人工检验

复现步骤

首先开代理进入openai 获取token
再修改token运行bot.py
报错
错误

卡着的页面

预期行为

正确执行

实际行为

深度截图_选择区域_20221214135611

日志信息

File "", line 1, in
File "/usr/lib/python3.10/multiprocessing/spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "/usr/lib/python3.10/multiprocessing/spawn.py", line 129, in _main
return self._bootstrap(parent_sentinel)
File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/home/lijun/.local/lib/python3.10/site-packages/uvicorn/_subprocess.py", line 76, in subprocess_started
target(sockets=sockets)
File "/home/lijun/.local/lib/python3.10/site-packages/uvicorn/server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/home/lijun/.local/lib/python3.10/site-packages/nonebot/message.py", line 142, in _check_matcher
await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
File "/home/lijun/.local/lib/python3.10/site-packages/nonebot/message.py", line 188, in _run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "/home/lijun/.local/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 727, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "/home/lijun/.local/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 702, in simple_run
await handler(
File "/home/lijun/.local/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 108, in call
return await cast(Callable[..., Awaitable[R]], self.call)(**values)
File "/home/lijun/.local/lib/python3.10/site-packages/nonebot_plugin_chatgpt/init.py", line 59, in ai_chat
msg = await chat_bot(**session[event]).get_chat_response(text)
File "/home/lijun/.local/lib/python3.10/site-packages/nonebot_plugin_chatgpt/chatgpt.py", line 94, in get_chat_response
await self.refresh_session()
File "/home/lijun/.local/lib/python3.10/site-packages/nonebot_plugin_chatgpt/chatgpt.py", line 151, in refresh_session
await self.refresh_session()
File "/home/lijun/.local/lib/python3.10/site-packages/nonebot_plugin_chatgpt/chatgpt.py", line 151, in refresh_session
await self.refresh_session()

File "/home/lijun/.local/lib/python3.10/site-packages/nonebot_plugin_chatgpt/chatgpt.py", line 150, in refresh_session
await self.get_cf_cookies()
File "/home/lijun/.local/lib/python3.10/site-packages/nonebot_plugin_chatgpt/chatgpt.py", line 222, in get_cf_cookies
self.cf_clearance = cf_clearance["value"]
TypeError: 'NoneType' object is not subscriptable

额外补充

No response

[BUG]:

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

git clone ,lastest

问题描述

任然没办法获取cf?
我配置了代理,但没有像别人那样一直刷cf,而是直接报错如下日志了。是需要额外什么配置吗,我并没有在readme看到
ubuntu20.04,python3.9.15

复现步骤

正常使用对话,过了很久回复获取session失败,请检查后台报错

预期行为

正常回复(至少也回复个连接超时什么的)

实际行为

失败

日志信息

image

额外补充

No response

[BUG]: 会将命令前缀识别为内容

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

0.7.0

问题描述

当启用机器人命令前缀和ChatGPT命令前缀时,会把ChatGPT命令前缀识别为内容,导致chatgpt回答受到命令前缀干扰

复现步骤

设置COMMAND_START 为 .
CHATGPT_COMMAND 为 &
使用.&内容 询问机器人

预期行为

No response

实际行为

它将CHATGPT COMMAND识别成了内容。如图
4B6B09F0-9604-4D14-A145-E6F23421FC62
09193B64-47C0-47BA-8CE3-B51C0D0A6FF1

日志信息

No response

额外补充

补充.env文件中的配置:
D8F2A161-2603-468E-BBAA-51C933814F8B
1D408685-FF6C-4612-911E-AAB01EEB32E2

[Feature]: 先有国内镜像chatgpt,不需要登入

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

现在每天都要重新换taken或者用VPN,感觉非常的麻烦

您想要的解决方案

能直接访问https://gpt.chatapi.art/这个镜像网站来进行chatgpt的交流,这样就不需要账号密码之类的东西来登入。

您考虑过的替代方案

No response

实现的功能是什么样的?

No response

还有什么要补充的吗?

No response

[BUG]: 使用账密登录会报Exception: State not found

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

0.4.0

问题描述

通过账密登录会报Exception: State not found错,账密确认没错,代理没问题,通过ssion访问是没问题的

复现步骤

账密登录

预期行为

No response

实际行为

No response

日志信息

No response

额外补充

No response

[BUG]: 无法刷新session

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

commit: 73ad1fc

问题描述

新版本的chatgpt对消息无响应,后台提示
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
挂在刷新session上
之前类似的问题是通过UA解决的,但是该版本已默认带有UA且尝试手动更改为其它系统UA但问题依旧
使用socks5走新加坡节点

复现步骤

100%触发

预期行为

No response

实际行为

No response

日志信息

File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/jason/zhenxun_bot/bot.py", line 21, in
nonebot.run()
File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/nonebot/init.py", line 273, in run
get_driver().run(*args, **kwargs)
File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 172, in run
uvicorn.run(
File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/uvicorn/main.py", line 576, in run
server.run()
File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/uvicorn/server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/nonebot/message.py", line 142, in _check_matcher
await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)

File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/nonebot/message.py", line 186, in _run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/nonebot/internal/matcher.py", line 716, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/nonebot/internal/matcher.py", line 688, in simple_run
await handler(
File "/home/jason/.cache/pypoetry/virtualenvs/zhenxun-bot-iiwV9KF4-py3.10/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 108, in call
return await cast(Callable[..., Awaitable[R]], self.call)(**values)
File "/home/jason/zhenxun_bot/plugins/nonebot_plugin_chatgpt/init.py", line 69, in ai_chat
msg = await chat_bot(**session[session_id]).get_chat_response(text)
File "/home/jason/zhenxun_bot/plugins/nonebot_plugin_chatgpt/chatgpt.py", line 63, in get_chat_response
await self.refresh_session()
File "/home/jason/zhenxun_bot/plugins/nonebot_plugin_chatgpt/chatgpt.py", line 93, in refresh_session
raise RuntimeError("Error refreshing session") from e
RuntimeError: Error refreshing session

额外补充

No response

[Feature]: 关于配置文件保存的路径

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

目前配置文件的保存路径被作者修改为了和代码文件同一路径,但是个人认为这并不是一个很好的方案,希望能够讨论一下,得知作者如此修改的原因
个人认为不是好的方案的原因如下:

  1. 部分python环境安装在管理员权限文件夹下,如果将配置文件置于此处可能会遇到读写权限问题
  2. 不方便查看和修改配置文件内容
  3. 代码与配置混在一起,文件目录结构不清晰

您想要的解决方案

目前大部分插件都使用data作为保存配置的目录,个人认为将配置保存在此处比较好

您考虑过的替代方案

No response

实现的功能是什么样的?

No response

还有什么要补充的吗?

No response

[BUG]: 无法在Arm设备上运行本插件

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

0.5.1

问题描述

我一般用树莓派设备来挂nonebot,树莓派是arm64架构的,今天运行这个插件的时候报错了,看了一下log,发现本插件调用了OpenAIAuth包来实现使用openai的账号密码获取token,而这个包调用了tls_client包,tls_client试图调用一个dll的时候,我的设备上就报错了。

看了一下https://github.com/acheong08/ChatGPT的readme,里面写的“
No ARM support for email/password. Use session token authentication if on Raspberry Pi”。发现不需要OpenAIAuth只用token应该也能登录,就把插件里涉及OpenAIAuth的几行代码删了,发现能正常运行

复现步骤

  1. 安装插件,并未报错
  2. 运行nonebot服务,chatgpt插件报错,其他功能正常
  3. 卸载并重新安装插件,错误依然存在,卸载并重新安装tls_client包,换用不同版本的OpenAIAuth包,重复步骤1 2,错误依然存在

预期行为

No response

实际行为

No response

日志信息

No response

额外补充

No response

[Feature]: 回答不满意,重新回答。

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认功能并未实现。
  • 我确定在 GitHub Issues 中没有相同或相似的需求。
  • 我有足够的时间和能力,愿意为此提交 PR 来实现功能。

您希望能解决什么样的问题?

有时候,QQchatgpt的回答并不让我满意,我想让他重新回答。

您想要的解决方案

我发现chatgpt网站上有个刷新按钮,一按就可以让他重新回答,不知道大佬能不能把这个按钮变成“重新回答”这样的指令。

您考虑过的替代方案

No response

实现的功能是什么样的?

No response

还有什么要补充的吗?

No response

[BUG]: 错误信息: LocalProtocolError: Illegal header value b'Bearer '

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

当前最新版本

问题描述

功能使用报错

复现步骤

正常艾特bot,发生报错,启动无报错,运行报错

预期行为

恢复正常使用

实际行为

No response

日志信息

return await self.request(

File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/httpx/_client.py", line 1506, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/httpx/_client.py", line 1593, in send
response = await self._send_handling_auth(
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/httpx/_client.py", line 1621, in _send_handling_auth
response = await self._send_handling_redirects(
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/httpx/_client.py", line 1658, in _send_handling_redirects
response = await self._send_single_request(request)
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/httpx/_client.py", line 1695, in _send_single_request
response = await transport.handle_async_request(request)
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/usr/lib/python3.9/contextlib.py", line 137, in exit
self.gen.throw(typ, value, traceback)
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-lAGE7ajM-py3.9/lib/python3.9/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ConnectError

额外补充

No response

[BUG]: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

报告清单

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。
  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

影响版本

v0.2.0 fe9a462

问题描述

命令成触发几次后,之后就再也没理我了,后台错误截图
QQ截图20221206133050

复现步骤

首先发送命令
然后没有回复
结果报错

预期行为

No response

实际行为

No response

日志信息

No response

额外补充

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.