一个通过 OpenAI 来对b站视频进行总结插件
Project description
📖 介绍
视频链接解析,并根据其内容生成基本信息、词云和内容总结
手机端视图
基本信息
词云
视频总结
## 总结
高通第二代骁龙7+的工程机,拥有台积电4nm工艺,CPU规格和骁龙8+一模一样,GPU规格上是新的Adreno 700架构,性能表现出众,能效曲线稍逊于8+,但中低频段能效水平相同,终端机价格如果能做到1500-2000元,竞争力还是很足的。
## 要点
- 💻 第二代骁龙7+拥有台积电4nm工艺和与骁龙8+一样的CPU规格。
- 🎮 新的Adreno 700架构GPU规格性能强,比上一代7Gen1强了超过一倍。
- 📈 能效曲线稍逊于8+,但中低频段能效水平相同。
- 💰 如果终端机价格做到1500-2000元,竞争力还是很足的。
- 🧪 高通自己也意识到骁龙7系列的竞争力问题,这也使其成了必须要解决的一个问题。
- 🕹️ 7+ Gen2就是8+的CPU,旗舰规格下放,最大的受益者是大型游戏。
💿 安装
使用 nb-cli 安装
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装nb plugin install nonebot-plugin-bilichat
注: 由于 nb-cli 不支持依赖组,因此需要启用词云和AI总结的用户要通过其他的包管理器安装额外的依赖
pip install nonebot-plugin-bilichat[all]
使用包管理器安装
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令pip
pip install nonebot-plugin-bilichat[all]
pdm
pdm add nonebot-plugin-bilichat[all]
poetry
poetry add nonebot-plugin-bilichat[all]
conda
conda install nonebot-plugin-bilichat[all]
打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入
plugins = ["nonebot_plugin_bilichat"]
⚙️ 配置
在 nonebot2 项目的.env文件中添加下表中的配置, 配置均为非必须项
通用配置项
| 配置项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| bilichat_block | bool | False | 是否拦截事件(防止其他插件二次解析) |
| bilichat_enable_private | bool | True | 是否允许响应私聊 |
| bilichat_enable_self | bool | False | 是否允许响应自身的消息 |
| bilichat_only_self | bool | False | 是否仅响应自身的消息,开启后会覆盖全部其他规则(人机合一特供) |
| bilichat_enable_channel | bool | True | 是否允许响应频道的消息 |
| bilichat_enable_unkown_src | bool | False | 是否允许响应未知来源的消息 |
| bilichat_whitelist | list[str] | [] | 响应的群聊(频道)名单, 会覆盖黑名单 |
| bilichat_blacklist | list[str] | [] | 不响应的群聊(频道)名单 |
| bilichat_dynamic_font | str | None | 视频信息及词云图片使用的字体 |
| bilichat_cd_time | int | 120 | 对同一视频的响应冷却时间(防止刷屏) |
| bilichat_neterror_retry | int | 3 | 对部分网络请求错误的尝试次数 |
| bilichat_use_bcut_asr | bool | True | 是否在没有字幕时调用必剪接口生成字幕 |
| bilichat_show_error_msg | bool | True | 是否在解析失败时发送错误信息 |
注:
- 由于 OneBot 协议未规定是否应上报自身事件,因此在不同的场景下能否获取自身事件并不一定,
bilichat_enable_self实际能否生效也与之相关 - 当
bilichat_whitelist存在时,bilichat_blacklist将会被禁用 bilichat_dynamic_font可填写自定义的字体url,但并不推荐修改- 当使用
bcut_asr接口来生成AI字幕时,根据视频时长和网络情况有可能会识别失败,Bot会提示BCut-ASR conversion failed due to network error。可以通过调高bilichat_neterror_retry次数或几分钟后重试来尝试重新生成字幕
基础信息配置项
| 配置项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| bilichat_basic_info | bool | True | 是否开启视频基本信息 |
| bilichat_basic_info_style | str | bbot_default | 视频详情的图片样式,可用样式见下方备注 |
| bilichat_basic_info_url | bool | True | 开启视频进本信息的情况下,是否一同回复一个链接 |
| bilichat_reply_to_basic_info | bool | True | 后续消息是否回复基础信息(关闭则回复发送者的信息) |
注:bilichat_basic_info_style 除默认的 bbot_default 使用 PIL 绘图,其他均依赖于 nonebot-plugin-htmlrender,其可用的样式如下所示
bbot_default
style_blue
词云配置项
开启此功能需要安装对应的依赖 nonebot-plugin-bilichat[wordcloud]
| 配置项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| bilichat_word_cloud | bool | True | 是否开启词云功能 |
注:词云功能在 python3.11 中由于 wordcloud 包安装失败暂时无法启用,请不要在 3.11 中开启此功能
AI视频总结配置项
开启此功能需要安装对应的依赖 nonebot-plugin-bilichat[openai,newbing]
| 配置项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| bilichat_newbing_cookie | str | None | newbing的cookie文件路径, 填写 no_login 则不进行登录(可能有次数限制), 若留空则禁用newbing总结 |
| bilichat_newbing_token_limit | int | 0 | newbing请求的文本量上限, 0为无上限 |
| bilichat_newbing_preprocess | bool | True | 是否对newbing的返回值进行预处理, 以去除其中不想要的内容 |
| bilichat_openai_token | str | None | openai的apikey, 若留空则禁用openai总结 |
| bilichat_openai_proxy | str | None | 访问openai或newbing使用的代理地址 |
| bilichat_openai_model | str | gpt-3.5-turbo-0301 | 使用的语言模型名称 |
| bilichat_openai_token_limit | int | 3500 | 请求的文本量上限, 计算方式可参考tiktoken |
注:
- openai 与 newbing 目前均需求科学上网才能使用,国内服务器请务必填写
bilichat_openai_proxy或全局透明代理 - 如果同时填写了
bilichat_openai_token和bilichat_newbing_cookie,则会使用newbing进行总结, 并在newbing总结失败时使用openai进行总结 newbing和openai均有缓存机制,同一视频在获取到正常的总结内容后不会重复发送请求,如需刷新请求内容可以 添加参数 或手动删除对应视频的缓存文件或整个缓存文件夹- 经测试,目前
newbing至少能总结 12000 字符以上的文本,推测 token 上限应为gpt-4-32k-0314的32200token,但过长的内容易造成输出内容包含额外内容或总结失败,因此也建议设置一个合理的 token 上限(反正不要钱,要啥自行车) - 由于
newbing限制较大,也不如openai听话,且需要联网查询资料,因此使用体验并不如 chatgpt(反正不要钱,要啥自行车) - newbing cookie 文件获取方式参考这里和这里。
目前 newbing 已正式公布且无需登录也可使用,填写目前无 cookie 使用失败概率极高,请谨慎考虑是否采用无 cookie 的方式。bilichat_newbing_cookie=no_login即可无 cookie 使用。
🎉 使用
直接发送视频(专栏)链接即可
参数表
在发送视频时,可以额外添加以下类似 shell 指令的参数,进而对解析流程进行调整。例如
BV12v4y1E7NT --refresh
BV12v4y1E7NT -r # 可以使用简写
BV12v4y1E7NT -r --no-cache # 可以多个参数混用
-r BV12v4y1E7NT -n # 虽然不建议,但确实可以把参数放前面
| 指令 | 简写 | 说明 |
|---|---|---|
| --no-cache | -n | 本次总结禁用缓存(不会影响已存在的缓存文件) |
| --refresh | -r | 刷新此视频的词云和总结缓存(会覆盖已存在的缓存文件) |
指令表
正在开发指令相关,请无视这里的模板 指令设计方案征集中,如果有什么想要实现的功能可以在issue中提出
| 指令 | 权限 | 需要@ | 范围 | 说明 |
|---|---|---|---|---|
| 指令1 | 主人 | 否 | 私聊 | 指令说明 |
| 指令2 | 群员 | 是 | 群聊 | 指令说明 |
🙏 感谢
在此感谢以下开发者(项目)对本项目做出的贡献:
- BibiGPT 项目灵感来源
- bilibili-API-collect 易姐收集的各种 BiliBili Api 及其提供的 gRPC Api 调用方案
- BBot-Graia 功能来源
(我 牛 我 自 己) - ABot-Graia 永远怀念最好的 ABot 🙏
- nonebot-plugin-template: 项目的 README 模板
- nonebot-plugin-bing-chat: newbing解析的代码参考
- Misaka-Mikoto-Tech 为本项目提交了多项BUG修复和代码参考
⏳ Star 趋势
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nonebot_plugin_bilichat-2.7.0.tar.gz.
File metadata
- Download URL: nonebot_plugin_bilichat-2.7.0.tar.gz
- Upload date:
- Size: 399.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db392a204e7dc392310757b38d06456f6766a9e22362b44b19edb7743b433973
|
|
| MD5 |
7b1f399efcc9b37c3fef1c4295c84efb
|
|
| BLAKE2b-256 |
b288f0774ffb5b8a33d0ae64fd725e8a3f20b2183d4b48dc65ea6f7866ea70ee
|
File details
Details for the file nonebot_plugin_bilichat-2.7.0-py3-none-any.whl.
File metadata
- Download URL: nonebot_plugin_bilichat-2.7.0-py3-none-any.whl
- Upload date:
- Size: 403.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de5e241866c3c99f8a81d2c0f2ca6269789620c13d5d54d84615d658be2a933e
|
|
| MD5 |
b358c975b519f10361d5b2c0ef54cd09
|
|
| BLAKE2b-256 |
9080b9ed0e73e61dc25636ea5fabbb4475699a29e08c761e4c16c45db3ad856c
|