Skip to main content

No project description provided

Project description

NoneBotPluginLogo

NoneBotPluginText

Nonebot-plugin-gpt3

3.3日更新: 支持gpt-3.5-turbo模型

✨ 基于OpenAI 官方API的对话插件 ✨

license Python NoneBot pypi download

功能

  • 上下文功能
  • 连续会话
  • 人格设置
  • 切换群聊/会话导出
  • 回答图片渲染

如何使用

私聊中是直接发送消息,群聊中是以回复的方式发送。

以下是功能列表

功能 指令
基本的聊天对话 基本会话(默认【gpt3】触发)
连续对话 chat/聊天/开始聊天
结束聊天 stop/结束/结束聊天
切换会话 切换群聊/切换会话/切换
重置会话记录 刷新/重置对话
重置AI人格 重置人格
设置AI人格 设置人格
导出历史会话 导出会话/导出对话
回答渲染为图片 图片渲染(默认关闭)

基本会话

对话前,加上默认前缀即可与GPT3对话。

连续会话

输入chat/聊天/开始聊天即可不加前缀,连续的对话,输入结束/结束聊天,即可结束聊天

人格设置

预设了AI助手/猫娘/nsfw猫娘三种人格,可以通过人格设置切换。内置的设定可以从这里看到

同样也可以手动指定人格

切换群聊

命令切换+群号即可保留聊天信息并切换群聊。

切换群聊到702280361

图片渲染

图片渲染可以在配置文件中选择配置是否需要渲染。

安装

  1. 使用 nb-cli
nb plugin install nonebot-plugin-gpt3
  1. 通过包管理器安装,可以通过nb,pip,或者poetry等方式安装,以pip为例
pip install nonebot-plugin-gpt3 -U

随后在bot.py中加上如下代码,加载插件

nonebot.load_plugin('nonebot_plugin_gpt3')

配置

对于官方OpenAI接口只需配置API Keys即可,所以请填写API在您的配置文件中配置API KEYS

openai_api_key = "xxx"                             # API密钥

此外可以通过环境变量配置,例如在Linux命令行中输入如下命令之后,直接启动即可

export openai_api_key="xxx"

之后是一些自定义配置,根据注释可以自行修改,如果需要请在对应的配置文件下进行配置。

gpt3_command_prefix = "."                          # 基本会话中的指令前缀
openai_api_key = "xxx"                             # API密钥

# 默认人格
gpt3_default_preset = "以下是与一个叫鸡哥的篮球高手的对话。你叫鸡哥,是一个唱跳rap篮球的高手,并且每句话后会带上厉不厉害你鸡哥!"
gpt3_proxy = "http://127.0.0.1:7890"               # 代理地址
gpt3_need_at = False                               # 是否需要@才触发命令
gpt3_image_render = False                          # 是否渲染为图片
gpt3_image_limit = 150                             # 长度超过多少才会渲染成图片
gpt3_max_tokens = 1000                             # 回答内容最大长度
gpt3_chat_count_per_day = 150                      # 普通用户每天聊天次数上限
gpt3_model = 'gpt-3.5-turbo'                       # 语言模型

图片渲染

如果需要开启图片渲染,请在配置文件中,配置gpt3_image_render = True

并安装playwright,如果已经安装了playwright则请忽略

pip3 install playwright && playwright install 

启动后出现PyTorch, TensorFlow等提示问题,忽略即可

image-20230118105930615

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_plugin_gpt3-1.1.9.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_gpt3-1.1.9-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_gpt3-1.1.9.tar.gz.

File metadata

  • Download URL: nonebot_plugin_gpt3-1.1.9.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.8.16 Darwin/21.6.0

File hashes

Hashes for nonebot_plugin_gpt3-1.1.9.tar.gz
Algorithm Hash digest
SHA256 8e0a8101c5e93b7da5a6941d86855d3d3f3eba9e942578e9b9962c9728500bcf
MD5 ec0ee90d5bdd7d95dbfdf46aed62ff14
BLAKE2b-256 769ae3e3b92721a9a65fd29534b2304d9357c7608c2b3ed3db3ed73edc041d41

See more details on using hashes here.

File details

Details for the file nonebot_plugin_gpt3-1.1.9-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_gpt3-1.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 b6835452c52b195b42a0e69e32559415e35fc6c8f18fd25d39da31acda1b0b1b
MD5 611e85a91f3a6cbcf4a5b243bb19973e
BLAKE2b-256 ca54af56cf27f8007f2d4331b3000202bda187e55b65baaaf159787c76b5e030

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page