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_PROXIES | 否 | None | 代理地址,格式为: http://ip:port |
CHATGPT_REFRESH_INTERVAL | 否 | 30 | session_token 自动刷新间隔,单位:分钟 |
CHATGPT_COMMAND | 否 | 空字符串 | 触发聊天的命令,可以是 字符串 或者 字符串列表 。如果为空字符串或者空列表,则默认响应全部消息 |
CHATGPT_TO_ME | 否 | True | 是否需要@机器人 |
CHATGPT_TIMEOUT | 否 | 10 | 请求的超时时间,单位:秒 |
获取 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.2.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30d5daf3808b6a2e1b77c187091e9ae64e51cbd2b2a4210f123107d4c06b6018 |
|
MD5 | 828e35815749caff796da4556f6d5b40 |
|
BLAKE2b-256 | 66fcd95345bd9522e72986409156e6ac4e3babcc66b0e988f759efc00111e733 |
Close
Hashes for nonebot_plugin_chatgpt-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36cbc4abf0aacc5669c71ca2ff623a8211d7279cc60c78e5c1b5ff754830ab1c |
|
MD5 | 5a5b8208486db31e02558f0af330e904 |
|
BLAKE2b-256 | 3395f81671be83b31038aa182ba5a29cec71d8cd11744f7041cc61c8c83d7528 |