Skip to main content

✨ Gemini AI 对话 NoneBot 插件 ✨

Project description

Nonebot Plugin Gemini

Google Gemini AI 对话插件

功能

命令 用途 示例
gemini <文本/图像> 单次调用 Gemini 并获取回复 gemini 编写一个 NoneBot2 的 echo 插件
geminichat [可选]<文本> 开启一轮与 Gemini 的对话 geminichat
结束对话 结束本轮对话 结束对话

关于 gemini 命令的使用:

  1. 你可以回复某条消息,并在句首加上 gemini 来调用 Gemini,并将回复中的文本/图片发送给 Gemini
  2. 你可以在 gemini 后加上 Gemini 的模型名称来指定使用的模型,插件支持的模型有 gemini-1.5-flash(默认), gemini-1.5-flash-8b, gemini-1.5-pro。例如 gemini gemini-1.5-pro 编写一个 NoneBot2 的 echo 插件
  3. geminichat 仅支持调用 gemini-1.5-flash 模型,因为 gemini-1.5-pro 的每天免费调用次数仅为 50 次

如果你配置了命令头,请在使用命令时将命令头加上

安装方法

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

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

plugins = ["nonebot_plugin_gemini"]

配置

Google AI Studio 获取 GOOGLE_API_KEY 后,在 .env 文件 或 环境变量 中添加 GOOGLE_API_KEY

配置项 默认值 说明
GOOGLE_API_KEY Google AI Studio 的 API Key
PROXY 可选。代理地址,格式为 http://ip:portsocks5://ip:port
IMAGE_RENDER_LENGTH 500 可选。超过这个数值的回复将会以 Markdown 渲染为图片

下面是网络搜索相关配置

配置项 默认值 说明
ENABLE_SEARCH false 是否启用网络搜索,启用会导致回答时间加长,但能提高回答的准确率
GOOGLE_CUSTOM_SEARCH_KEY Google Custom Search 的 API Key,可到 此处 获取
GOOGLE_CUSTOM_SEARCH_CX 可选。Google Custom Search 的 CX,可到 此处 创建
GOOGLE_CUSTOM_SEARCH_NUM 3 可选。Google Custom Search 的搜索结果数量
SEARCH_KEYWORDS_PROMPT ... 可选。用 Gemini 提取搜索关键词时使用的提示词

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_gemini-0.5.0.tar.gz (7.2 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_gemini-0.5.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_gemini-0.5.0.tar.gz.

File metadata

  • Download URL: nonebot_plugin_gemini-0.5.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.21.0 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for nonebot_plugin_gemini-0.5.0.tar.gz
Algorithm Hash digest
SHA256 af353111e3b008acc7bed6398e2013f20e690a00cc0c530c4f879ef1a563c88a
MD5 9fce81eb9cd693356c3c44cbcf068f2e
BLAKE2b-256 784253b2f16e3406f0a88fee62d037e59c17c4ed63b49bf1c96d38b28e8e05f5

See more details on using hashes here.

File details

Details for the file nonebot_plugin_gemini-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_gemini-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39c2d0d80533e9c878a1204e4672d7d100d1359c0a9f5ee41f24a2965af4a5fd
MD5 bd0bef0f92f837d622a8d82f955b87b4
BLAKE2b-256 f6fa17f16c119cfc68d44a6a9addab483e581a3b81ac0fa24494de71242d1449

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