Skip to main content

利用 LLM 将自然语言转换为机器人指令 / Convert natural language messages into bot commands using LLMs

Project description

NoneBot-Plugin-LLM-Extension

✨ 将自然语言转换为机器人指令 ✨

pypi python uv-managed alc-resolved
NoneBot Registry Supported Adapters
📸 演示与预览   |   📦️ 下载插件   |   💬 加入交流群

📖 介绍 Human coded

利用 LLM 将自然语言转换为机器人指令 / Convert natural language messages into bot commands using LLMs

[!IMPORTANT] 收藏项目,你将从 GitHub 上无延迟地接收所有发布通知~⭐️

starify

💿 安装

以下提到的方法任选 其一 即可

[推荐] 使用 nb-cli 安装 在 Bot 的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-llm-extension
使用包管理器安装
pip install nonebot-plugin-llm-extension
# or, use poetry
poetry add nonebot-plugin-llm-extension
# or, use pdm
pdm add nonebot-plugin-llm-extension
# or, use uv
uv add nonebot-plugin-llm-extension

⚙️ 配置

在项目的配置文件中添加下表中配置:

其实这里并不建议使用 deepseek

配置项 默认值 说明
llm_extension__api_key API 密钥
llm_extension__base_url https://api.deepseek.com/v1 API 端点
llm_extension__model deepseek-reasoner 模型名

🎉 使用

[!NOTE] 为了使 LLM 能够更好地理解和转换用户输入为指令,建议在构造指令时:

  1. 完善命令描述:为每个命令提供清晰、准确的描述信息
  2. 丰富参数说明:详细说明每个参数的含义、类型和取值范围
  3. 提供使用示例:给出具体的操作示例,帮助 LLM 理解命令的使用场景
from nonebot_plugin_llm_extension import LLMExtension
from nonebot_plugin_alconna import on_alconna, Args, Alconna, CommandMeta

weather = on_alconna(
    Alconna(
      "weather",
      Args["location?#地区", str],
      meta=CommandMeta(
        description="今日天气",
        example="/天气 陕西汉中"
      )
    ), 
    use_cmd_start=True,
    extension=[LLMExtension],
)

通过提供完善的命令元信息,可以让 LLM 更准确地理解命令意图,从而提高自然语言到指令的转换准确率

📸 效果图

理论上,这里应该有一张图片

💖 鸣谢

📄 许可证

本项目使用 MIT 许可证开源

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

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_llm_extension-0.1.1.tar.gz (6.1 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_llm_extension-0.1.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_llm_extension-0.1.1.tar.gz.

File metadata

File hashes

Hashes for nonebot_plugin_llm_extension-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0e98e983c5d7f27aa4c20fea5f741e4262efd09a463a6b4921948584283a5bef
MD5 904a12d5a31ccd64fdcaa60938b569b2
BLAKE2b-256 2e4f8b93ca653eb9aee60356399701fdf0ab1daceac4b737f1f96941935a6f7d

See more details on using hashes here.

File details

Details for the file nonebot_plugin_llm_extension-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_llm_extension-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cf80d9ac5a4f971f66e9679fa591417b7a342566f73390cc2b7f633a90d7dc81
MD5 711b8cd097b88f1d0c84990bb1ea868c
BLAKE2b-256 5eb0cb244d12507525de56bd79f2223ae1546d663094aa4e46012c63b698b94a

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