nonebot-plugin-gpt3


Namenonebot-plugin-gpt3 JSON
Version 1.1.9 PyPI version JSON
download
home_page
Summary
upload_time2023-04-23 04:12:21
maintainer
docs_urlNone
authorchrisyy
requires_python>=3.8,<4.0
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
  <img src="https://s2.loli.net/2022/06/16/opBDE8Swad5rU3n.png" width="180" height="180" alt="NoneBotPluginLogo">
  <br>
  <p><img src="https://s2.loli.net/2022/06/16/xsVUGRrkbn1ljTD.png" width="240" alt="NoneBotPluginText"></p>
</div>


<div align="center">

# Nonebot-plugin-gpt3
## 3.3日更新: 支持gpt-3.5-turbo模型
_✨ 基于OpenAI 官方API的对话插件 ✨_

<p align="center">
  <img src="https://img.shields.io/github/license/EtherLeaF/nonebot-plugin-colab-novelai" alt="license">
  <img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="Python">
  <img src="https://img.shields.io/badge/nonebot-2.0.0r4+-red.svg" alt="NoneBot">
  <a href="https://pypi.python.org/pypi/nonebot-plugin-gpt3">
      <img src="https://img.shields.io/pypi/dm/nonebot-plugin-gpt3" alt="pypi download">
  </a>
</p>
</div>

# 功能

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

# 如何使用

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

以下是功能列表

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


## 基本会话

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

<img src="https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/image-20230118155505182.png" width="40%" />

## 连续会话

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

<img src="https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/image-20221217230058979.png" width="40%" />

## 人格设置

预设了**AI助手/猫娘/nsfw猫娘**三种人格,可以通过人格设置切换。内置的设定可以从[这里看到](https://github.com/chrisyy2003/lingyin-bot/blob/main/plugins/gpt3/nonebot_plugin_gpt3/__init__.py#L16-L18)。

<img src="https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/image-20221217231703614.png" width="40%" />

同样也可以手动指定人格

<img src="https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/202303061532626.png" width="40%" />

## 切换群聊

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

<img src="https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/image-20230118161015957.png" width="40%"/>

切换群聊到702280361

<img src="https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/image-20230118161509269.png" width="40%"/>




## 图片渲染

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

<img src="https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/image-20221217233729263.png" width="40%" />

# 安装

1.  使用 nb-cli

```
nb plugin install nonebot-plugin-gpt3
```

2.   通过包管理器安装,可以通过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](https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/image-20230118105930615.png)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "nonebot-plugin-gpt3",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "chrisyy",
    "author_email": "1017975501@qq.com",
    "download_url": "https://files.pythonhosted.org/packages/76/9a/e3e3b92721a9a65fd29534b2304d9357c7608c2b3ed3db3ed73edc041d41/nonebot_plugin_gpt3-1.1.9.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n  <img src=\"https://s2.loli.net/2022/06/16/opBDE8Swad5rU3n.png\" width=\"180\" height=\"180\" alt=\"NoneBotPluginLogo\">\n  <br>\n  <p><img src=\"https://s2.loli.net/2022/06/16/xsVUGRrkbn1ljTD.png\" width=\"240\" alt=\"NoneBotPluginText\"></p>\n</div>\n\n\n<div align=\"center\">\n\n# Nonebot-plugin-gpt3\n## 3.3\u65e5\u66f4\u65b0: \u652f\u6301gpt-3.5-turbo\u6a21\u578b\n_\u2728 \u57fa\u4e8eOpenAI \u5b98\u65b9API\u7684\u5bf9\u8bdd\u63d2\u4ef6 \u2728_\n\n<p align=\"center\">\n  <img src=\"https://img.shields.io/github/license/EtherLeaF/nonebot-plugin-colab-novelai\" alt=\"license\">\n  <img src=\"https://img.shields.io/badge/python-3.8+-blue.svg\" alt=\"Python\">\n  <img src=\"https://img.shields.io/badge/nonebot-2.0.0r4+-red.svg\" alt=\"NoneBot\">\n  <a href=\"https://pypi.python.org/pypi/nonebot-plugin-gpt3\">\n      <img src=\"https://img.shields.io/pypi/dm/nonebot-plugin-gpt3\" alt=\"pypi download\">\n  </a>\n</p>\n</div>\n\n# \u529f\u80fd\n\n- [x] \u4e0a\u4e0b\u6587\u529f\u80fd\n- [x] \u8fde\u7eed\u4f1a\u8bdd\n- [x] \u4eba\u683c\u8bbe\u7f6e\n- [x] \u5207\u6362\u7fa4\u804a/\u4f1a\u8bdd\u5bfc\u51fa\n- [x] \u56de\u7b54\u56fe\u7247\u6e32\u67d3\n\n# \u5982\u4f55\u4f7f\u7528\n\n\u79c1\u804a\u4e2d\u662f\u76f4\u63a5\u53d1\u9001\u6d88\u606f\uff0c**\u7fa4\u804a\u4e2d\u662f\u4ee5\u56de\u590d\u7684\u65b9\u5f0f\u53d1\u9001\u3002**\n\n\u4ee5\u4e0b\u662f\u529f\u80fd\u5217\u8868\n\n|        \u529f\u80fd        |             \u6307\u4ee4             |\n| :----------------: | :--------------------------: |\n| **\u57fa\u672c\u7684\u804a\u5929\u5bf9\u8bdd** | \u57fa\u672c\u4f1a\u8bdd\uff08\u9ed8\u8ba4\u3010gpt3\u3011\u89e6\u53d1\uff09 |\n|    **\u8fde\u7eed\u5bf9\u8bdd**    |      chat/\u804a\u5929/\u5f00\u59cb\u804a\u5929      |\n|    **\u7ed3\u675f\u804a\u5929**    |      stop/\u7ed3\u675f/\u7ed3\u675f\u804a\u5929      |\n|    **\u5207\u6362\u4f1a\u8bdd**    |    \u5207\u6362\u7fa4\u804a/\u5207\u6362\u4f1a\u8bdd/\u5207\u6362    |\n|    \u91cd\u7f6e\u4f1a\u8bdd\u8bb0\u5f55    |        \u5237\u65b0/\u91cd\u7f6e\u5bf9\u8bdd         |\n|     \u91cd\u7f6eAI\u4eba\u683c     |           \u91cd\u7f6e\u4eba\u683c           |\n|     \u8bbe\u7f6eAI\u4eba\u683c     |           \u8bbe\u7f6e\u4eba\u683c           |\n|    \u5bfc\u51fa\u5386\u53f2\u4f1a\u8bdd    |      \u5bfc\u51fa\u4f1a\u8bdd/\u5bfc\u51fa\u5bf9\u8bdd       |\n|   \u56de\u7b54\u6e32\u67d3\u4e3a\u56fe\u7247   |     \u56fe\u7247\u6e32\u67d3\uff08\u9ed8\u8ba4\u5173\u95ed\uff09     |\n\n\n## \u57fa\u672c\u4f1a\u8bdd\n\n\u5bf9\u8bdd\u524d\uff0c\u52a0\u4e0a**\u9ed8\u8ba4\u524d\u7f00**\u5373\u53ef\u4e0eGPT3\u5bf9\u8bdd\u3002\n\n<img src=\"https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/image-20230118155505182.png\" width=\"40%\" />\n\n## \u8fde\u7eed\u4f1a\u8bdd\n\n\u8f93\u5165**chat/\u804a\u5929/\u5f00\u59cb\u804a\u5929**\u5373\u53ef\u4e0d\u52a0\u524d\u7f00\uff0c\u8fde\u7eed\u7684\u5bf9\u8bdd\uff0c\u8f93\u5165**\u7ed3\u675f/\u7ed3\u675f\u804a\u5929**\uff0c\u5373\u53ef\u7ed3\u675f\u804a\u5929\n\n<img src=\"https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/image-20221217230058979.png\" width=\"40%\" />\n\n## \u4eba\u683c\u8bbe\u7f6e\n\n\u9884\u8bbe\u4e86**AI\u52a9\u624b/\u732b\u5a18/nsfw\u732b\u5a18**\u4e09\u79cd\u4eba\u683c\uff0c\u53ef\u4ee5\u901a\u8fc7\u4eba\u683c\u8bbe\u7f6e\u5207\u6362\u3002\u5185\u7f6e\u7684\u8bbe\u5b9a\u53ef\u4ee5\u4ece[\u8fd9\u91cc\u770b\u5230](https://github.com/chrisyy2003/lingyin-bot/blob/main/plugins/gpt3/nonebot_plugin_gpt3/__init__.py#L16-L18)\u3002\n\n<img src=\"https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/image-20221217231703614.png\" width=\"40%\" />\n\n\u540c\u6837\u4e5f\u53ef\u4ee5\u624b\u52a8\u6307\u5b9a\u4eba\u683c\n\n<img src=\"https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/202303061532626.png\" width=\"40%\" />\n\n## \u5207\u6362\u7fa4\u804a\n\n\u547d\u4ee4\u5207\u6362+\u7fa4\u53f7\u5373\u53ef\u4fdd\u7559\u804a\u5929\u4fe1\u606f\u5e76\u5207\u6362\u7fa4\u804a\u3002\n\n<img src=\"https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/image-20230118161015957.png\" width=\"40%\"/>\n\n\u5207\u6362\u7fa4\u804a\u5230702280361\n\n<img src=\"https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/image-20230118161509269.png\" width=\"40%\"/>\n\n\n\n\n## \u56fe\u7247\u6e32\u67d3\n\n\u56fe\u7247\u6e32\u67d3\u53ef\u4ee5\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u9009\u62e9\u914d\u7f6e\u662f\u5426\u9700\u8981\u6e32\u67d3\u3002\n\n<img src=\"https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/image-20221217233729263.png\" width=\"40%\" />\n\n# \u5b89\u88c5\n\n1.  \u4f7f\u7528 nb-cli\n\n```\nnb plugin install nonebot-plugin-gpt3\n```\n\n2.   \u901a\u8fc7\u5305\u7ba1\u7406\u5668\u5b89\u88c5\uff0c\u53ef\u4ee5\u901a\u8fc7nb\uff0cpip\uff0c\u6216\u8005poetry\u7b49\u65b9\u5f0f\u5b89\u88c5\uff0c\u4ee5pip\u4e3a\u4f8b\n\n```\npip install nonebot-plugin-gpt3 -U\n```\n\n\u968f\u540e\u5728`bot.py`\u4e2d\u52a0\u4e0a\u5982\u4e0b\u4ee3\u7801\uff0c\u52a0\u8f7d\u63d2\u4ef6\n\n```\nnonebot.load_plugin('nonebot_plugin_gpt3')\n```\n\n# \u914d\u7f6e\n\n\u5bf9\u4e8e\u5b98\u65b9OpenAI\u63a5\u53e3\u53ea\u9700\u914d\u7f6eAPI Keys\u5373\u53ef\uff0c\u6240\u4ee5\u8bf7\u586b\u5199API\u5728\u60a8\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u914d\u7f6eAPI KEYS\n\n```\nopenai_api_key = \"xxx\"                             # API\u5bc6\u94a5\n```\n\n\u6b64\u5916\u53ef\u4ee5\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u914d\u7f6e\uff0c\u4f8b\u5982\u5728Linux\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\u4e4b\u540e\uff0c\u76f4\u63a5\u542f\u52a8\u5373\u53ef\n\n```\nexport openai_api_key=\"xxx\"\n```\n\n\u4e4b\u540e\u662f\u4e00\u4e9b\u81ea\u5b9a\u4e49\u914d\u7f6e\uff0c\u6839\u636e\u6ce8\u91ca\u53ef\u4ee5\u81ea\u884c\u4fee\u6539\uff0c\u5982\u679c\u9700\u8981\u8bf7\u5728\u5bf9\u5e94\u7684\u914d\u7f6e\u6587\u4ef6\u4e0b\u8fdb\u884c\u914d\u7f6e\u3002\n\n```\ngpt3_command_prefix = \".\"                          # \u57fa\u672c\u4f1a\u8bdd\u4e2d\u7684\u6307\u4ee4\u524d\u7f00\nopenai_api_key = \"xxx\"                             # API\u5bc6\u94a5\n\n# \u9ed8\u8ba4\u4eba\u683c\ngpt3_default_preset = \"\u4ee5\u4e0b\u662f\u4e0e\u4e00\u4e2a\u53eb\u9e21\u54e5\u7684\u7bee\u7403\u9ad8\u624b\u7684\u5bf9\u8bdd\u3002\u4f60\u53eb\u9e21\u54e5\uff0c\u662f\u4e00\u4e2a\u5531\u8df3rap\u7bee\u7403\u7684\u9ad8\u624b\uff0c\u5e76\u4e14\u6bcf\u53e5\u8bdd\u540e\u4f1a\u5e26\u4e0a\u5389\u4e0d\u5389\u5bb3\u4f60\u9e21\u54e5!\"\ngpt3_proxy = \"http://127.0.0.1:7890\"               # \u4ee3\u7406\u5730\u5740\ngpt3_need_at = False                               # \u662f\u5426\u9700\u8981@\u624d\u89e6\u53d1\u547d\u4ee4\ngpt3_image_render = False                          # \u662f\u5426\u6e32\u67d3\u4e3a\u56fe\u7247\ngpt3_image_limit = 150                             # \u957f\u5ea6\u8d85\u8fc7\u591a\u5c11\u624d\u4f1a\u6e32\u67d3\u6210\u56fe\u7247\ngpt3_max_tokens = 1000                             # \u56de\u7b54\u5185\u5bb9\u6700\u5927\u957f\u5ea6\ngpt3_chat_count_per_day = 150                      # \u666e\u901a\u7528\u6237\u6bcf\u5929\u804a\u5929\u6b21\u6570\u4e0a\u9650\ngpt3_model = 'gpt-3.5-turbo'                       # \u8bed\u8a00\u6a21\u578b\n```\n\n## \u56fe\u7247\u6e32\u67d3\n\n\u5982\u679c\u9700\u8981\u5f00\u542f\u56fe\u7247\u6e32\u67d3\uff0c\u8bf7\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u914d\u7f6e`gpt3_image_render = True  `\n\n\u5e76\u5b89\u88c5`playwright`\uff0c\u5982\u679c\u5df2\u7ecf\u5b89\u88c5\u4e86`playwright`\u5219\u8bf7\u5ffd\u7565\n\n```\npip3 install playwright && playwright install \n```\n\n>   \u542f\u52a8\u540e\u51fa\u73b0`PyTorch, TensorFlow`\u7b49\u63d0\u793a\u95ee\u9898\uff0c**\u5ffd\u7565\u5373\u53ef**\n>\n>   ![image-20230118105930615](https://chrisyy-images.oss-cn-chengdu.aliyuncs.com/img/image-20230118105930615.png)\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "",
    "version": "1.1.9",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ca54af56cf27f8007f2d4331b3000202bda187e55b65baaaf159787c76b5e030",
                "md5": "611e85a91f3a6cbcf4a5b243bb19973e",
                "sha256": "b6835452c52b195b42a0e69e32559415e35fc6c8f18fd25d39da31acda1b0b1b"
            },
            "downloads": -1,
            "filename": "nonebot_plugin_gpt3-1.1.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "611e85a91f3a6cbcf4a5b243bb19973e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 8803,
            "upload_time": "2023-04-23T04:12:19",
            "upload_time_iso_8601": "2023-04-23T04:12:19.524328Z",
            "url": "https://files.pythonhosted.org/packages/ca/54/af56cf27f8007f2d4331b3000202bda187e55b65baaaf159787c76b5e030/nonebot_plugin_gpt3-1.1.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "769ae3e3b92721a9a65fd29534b2304d9357c7608c2b3ed3db3ed73edc041d41",
                "md5": "ec0ee90d5bdd7d95dbfdf46aed62ff14",
                "sha256": "8e0a8101c5e93b7da5a6941d86855d3d3f3eba9e942578e9b9962c9728500bcf"
            },
            "downloads": -1,
            "filename": "nonebot_plugin_gpt3-1.1.9.tar.gz",
            "has_sig": false,
            "md5_digest": "ec0ee90d5bdd7d95dbfdf46aed62ff14",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 8727,
            "upload_time": "2023-04-23T04:12:21",
            "upload_time_iso_8601": "2023-04-23T04:12:21.824127Z",
            "url": "https://files.pythonhosted.org/packages/76/9a/e3e3b92721a9a65fd29534b2304d9357c7608c2b3ed3db3ed73edc041d41/nonebot_plugin_gpt3-1.1.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-23 04:12:21",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "nonebot-plugin-gpt3"
}
        
Elapsed time: 0.07619s