Skip to main content

NoneBot2 plugin for AI chat with OpenAI API.

Project description

NoneBotPluginLogo

NoneBotPluginText

nonebot-plugin-chatgpt-api

✨ ChatGPT (OpenAI API 接口版) ✨

license pypi python

📖 介绍

通过调用 OpenAI API 接口进行多轮对话、图像生成等任务,支持 ChatGPT、Genimi、DeepSeek 等多个模型。基于 nonebot-plugin-chatgpt 插件进行修改和扩展,提供更高效的 API 调用和自定义配置。

💿 安装

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

打开 nonebot2 项目的 bot.py 文件,在其中写入:

nonebot.load_plugin('nonebot_plugin_chatgpt_api')

⚙️ 配置

在 nonebot2 项目的 .env 文件中添加下表中的必填配置:

配置项 必填 默认值 说明
chatgpt_api_key OpenAI API 密钥
chatgpt_base_url None OpenAI API 调用的 URL
chatgpt_http_proxy_url None HTTP 代理地址
chatgpt_model gpt-4o 调用的模型名称
chatgpt_bot_name ChatGPT 机器人的名称(用于一些特定回复)
chatgpt_gen_args_json_file None 生成参数的 JSON 文件路径
chatgpt_return_image False 是否将回复以 markdown 格式渲染为图片
chatgpt_cd_time 5 聊天对话的冷却时间(秒)
chatgpt_timeout_time_chat 10 聊天的超时时间(分钟)
chatgpt_timeout_time_setting 5 与设置相关的命令的超时时间(分钟)
chatgpt_timeout_respond True 超时后是否自动回复
chatgpt_log_api_stats True 是否保存 API 调用统计信息日志
chatgpt_log_system_prompt True 是否保存系统提示词历史日志
chatgpt_log_chat_history True 是否保存对话历史日志

如果要更改日志保存路径,请在 .env 文件中额外设置 LOCALSTORE_CACHE_DIR,默认路径请参考此处

🎉 使用

默认配置下,@机器人加任意文本即可开始聊天。

指令 范围 说明
/帮助 群聊/私聊 查看插件的使用帮助
@机器人 提示词 群聊/私聊 修改系统提示词
@机器人 刷新 群聊/私聊 开启新的对话
@机器人 恢复 群聊/私聊 恢复上次的对话

🤝 贡献

🎉 鸣谢

感谢以下开发者对该项目做出的贡献:

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_chatgpt_api-1.1.5.tar.gz (18.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_chatgpt_api-1.1.5-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_chatgpt_api-1.1.5.tar.gz.

File metadata

File hashes

Hashes for nonebot_plugin_chatgpt_api-1.1.5.tar.gz
Algorithm Hash digest
SHA256 f354e06082a0764f925a9c556e139ae83d7796ce5aca28c4bc9e5ed47bde52b3
MD5 454f66cb7f7ab0cc81235e7f5978940d
BLAKE2b-256 9f4010bc70fcd67f51198a75cd3c4b973d7f9eb159c11ecde651be7fe427f5a6

See more details on using hashes here.

File details

Details for the file nonebot_plugin_chatgpt_api-1.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_chatgpt_api-1.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0aab9c01598a58ffb80828890997281c9021dddfcf30730bdab103addc22c5b6
MD5 cd8e175bd2fd910e74b838732542f03c
BLAKE2b-256 02c16c194aa6125d98f2a044f0219eaab31670c4865b4c631e1f15e9cfd9629e

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