Skip to main content

文心一言 Nonebot 插件

Project description

NoneBotPluginLogo

NoneBotPluginText

nonebot-plugin-ernie

✨ 简单的文心一言 AI 对话插件 ✨

license pypi python

📖 介绍

  • 本插件使用千帆ModelBuilder的推理服务 API进行对话请求。推理服务 API分为V1和V2两个互不兼容的版本,使用前请根据希望使用的版本进行配置。
  • V1版本使用前需根据API调用指南创建一个千帆应用以获取API Key、Secret Key。
  • V2版本使用前需根据认证鉴权指南创建一个千帆应用以获取API Key、AppID。
  • 支持的API列表:V1V2,默认为ernie-4.0-turbo-8k(V1和V2版本均可使用此模型)。

💿 安装

使用 nb-cli 安装(推荐) 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-ernie
使用包管理器安装 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
pip
pip install nonebot-plugin-ernie
pdm
pdm add nonebot-plugin-ernie
poetry
poetry add nonebot-plugin-ernie
conda
conda install nonebot-plugin-ernie

打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入

plugins = ["nonebot_plugin_example"]
手动安装
git clone https://github.com/Noctulus/nonebot-plugin-ernie.git

下载完成后在bot项目的pyproject.toml文件手动添加插件:

plugin_dirs = ["xxxxxx","xxxxxx",......,"下载完成的插件路径/nonebot-plugin-ernie"]

⚙️ 配置

根据选择的API版本,在 nonebot2 项目的.env文件中添加下表中的必填配置

配置项 必填 默认值 说明
wenxin_api_type V1 为了向前兼容性默认使用V1(真的有其他人在用这个插件吗?)
wenxin_ak V1是 推理服务API V1的API Key
wenxin_sk V1是 推理服务API V1的Secret Key
wenxin_api_key V2是 推理服务API V2的API Key
wenxin_appid V2是 V2版本应用ID
wenxin_model ernie-4.0-turbo-8k 百度智能云千帆模型
wenxin_sendpic False 是否以图片形式发送
wenxin_timeout 60 调用API多久无反应视为超时

Note: 若调用Deepseek R1等大型模型,60秒以上的响应时间都是有可能的,请适当增加wenxin_timeout,并坐和放宽

🎉 使用

指令表

指令 权限 需要@ 范围 说明
一言 全部 全部 使用文心一言 API 进行对话生成
绘图 全部 全部 使用文心一言 API 进行文生图作画

Note: V1版本虽然支持部分文生图API,但经实测文审过于严格几乎处于不可用状态,故绘图仅支持在V2版本下使用。

效果图

效果图

  • 如果配置了以图片形式发送(wenxin_sendpic=True),可以将Markdown形式的回答以更易读的方式呈现: Markdown效果图

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_ernie-1.1.0.tar.gz (5.8 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_ernie-1.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_ernie-1.1.0.tar.gz.

File metadata

  • Download URL: nonebot_plugin_ernie-1.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nonebot_plugin_ernie-1.1.0.tar.gz
Algorithm Hash digest
SHA256 9d1fd71e046d0872ecffc81c1805bc4b755e94de920e33421c8b47e73f572854
MD5 35e6cd281ea76cb09409b4b5b4257a81
BLAKE2b-256 b5b6e9e23aab7d9c25e8155692ea388e9b4b1c73abfc3cf0e32888e16ec08d26

See more details on using hashes here.

File details

Details for the file nonebot_plugin_ernie-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_ernie-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbf2ca5764a6379143023d594290d219019afc558873d6a2fb114d80528d71af
MD5 e7a86f06f10559734a795f9017196b9a
BLAKE2b-256 aa12da94f07ef2e503cdbd10995ee18714d479306fbfb66789f368abfbcfd28e

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