NoneBot2 plugin for AI chat
Project description
📖 介绍
智能对话聊天插件,核心部分参考 acheong08/ChatGPT 实现。
💿 安装
使用 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
文件中添加下表中的必填配置
配置项 | 必填 | 默认值 | 说明 |
---|---|---|---|
CHATGPT_SESSION_TOKEN | 否 | 空字符串 | ChatGPT 的 session_token,如配置则优先使用 |
CHATGPT_ACCOUNT | 否 | 空字符串 | ChatGPT 登陆邮箱,未配置则使用 session_token |
CHATGPT_PASSWORD | 否 | 空字符串 | ChatGPT 登陆密码,未配置则使用 session_token |
CHATGPT_PROXIES | 否 | None | 代理地址,格式为: http://ip:port |
CHATGPT_REFRESH_INTERVAL | 否 | 30 | session_token 自动刷新间隔,单位:分钟 |
CHATGPT_COMMAND | 否 | 空字符串 | 触发聊天的命令,可以是 字符串 或者 字符串列表 。如果为空字符串或者空列表,则默认响应全部消息 |
CHATGPT_TO_ME | 否 | True | 是否需要@机器人 |
CHATGPT_TIMEOUT | 否 | 10 | 请求的超时时间,单位:秒 |
CHATGPT_API | 否 | https://chat.openai.com/ | API 地址,可配置反代 |
CHATGPT_IMAGE | 否 | False | 是否以图片形式发送。 如果启动时出现 NotImplementedError 错误,请在 .env.dev 中将 fastapi_reload 设置为 False 如果无法显示文字,请点击此处查看解决办法 |
获取 session_token
- 登录 https://chat.openai.com/chat
- 按
F12
打开控制台 - 切换到
Application/应用
选项卡,找到Cookies
- 复制
__Secure-next-auth.session-token
的值,配置到CHATGPT_SESSION_TOKEN
即可
🎉 使用
默认配置下,@机器人加任意文本即可。
如果需要修改插件的触发方式,自定义 CHATGPT_COMMAND
和 CHATGPT_TO_ME
配置项即可。
指令 | 需要@ | 范围 | 说明 |
---|---|---|---|
刷新会话/刷新对话 | 是 | 群聊/私聊 | 重置会话记录,开始新的对话 |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for nonebot-plugin-chatgpt-0.4.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 668594ceab063c298239a1b363024211e901759a9c9694504c38b6047e97340f |
|
MD5 | 0b4cc5c9186c43fad30c361f61ba71cb |
|
BLAKE2b-256 | 4ccbcc1d1d077d3c5733bb765539622fdb25636256e3ce1e9cc54c5ee516fbf4 |
Close
Hashes for nonebot_plugin_chatgpt-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba9fc3e55c52507ef87f148c35286fb49595830c9452392b40c45ab5006e1131 |
|
MD5 | 471e48edb9698aabc98924914ce8af64 |
|
BLAKE2b-256 | 8ee307281f3525be0bf18480a1992420695861a29315b1e1164697d6b6d6d6a1 |